(KeyEvent e)
| 73 | // Add key listener to UP, DOWN, ESC keys for command history traversal. |
| 74 | textField.addKeyListener(new KeyAdapter() { |
| 75 | @Override |
| 76 | public void keyPressed(KeyEvent e) { |
| 77 | switch (e.getKeyCode()) { |
| 78 | |
| 79 | // Select previous command. |
| 80 | case KeyEvent.VK_UP: |
| 81 | if (commandHistory.hasPreviousCommand()) { |
| 82 | textField.setText( |
| 83 | commandHistory.getPreviousCommand(textField.getText())); |
| 84 | } |
| 85 | break; |
| 86 | |
| 87 | // Select next command. |
| 88 | case KeyEvent.VK_DOWN: |
| 89 | if (commandHistory.hasNextCommand()) { |
| 90 | textField.setText(commandHistory.getNextCommand()); |
| 91 | } |
| 92 | break; |
| 93 | |
| 94 | // Reset history location, restoring the last unexecuted command. |
| 95 | case KeyEvent.VK_ESCAPE: |
| 96 | textField.setText(commandHistory.resetHistoryLocation()); |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | }); |
| 101 | } |
| 102 |
nothing calls this directly
no test coverage detected