コード例 #1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   final NavBarKeyboardCommand cmd = NavBarKeyboardCommand.fromString(e.getActionCommand());
   if (cmd != null) {
     switch (cmd) {
       case LEFT:
         myPanel.moveLeft();
         break;
       case RIGHT:
         myPanel.moveRight();
         break;
       case HOME:
         myPanel.moveHome();
         break;
       case END:
         myPanel.moveEnd();
         break;
       case DOWN:
         myPanel.moveDown();
         break;
       case UP:
         myPanel.moveDown();
         break;
       case ENTER:
         myPanel.enter();
         break;
       case ESCAPE:
         myPanel.escape();
         break;
       case NAVIGATE:
         myPanel.navigate();
         break;
     }
   }
 }
コード例 #2
0
 NavBarListener(NavBarPanel panel) {
   myPanel = panel;
   for (NavBarKeyboardCommand command : NavBarKeyboardCommand.values()) {
     registerKey(command);
   }
   myPanel.addFocusListener(this);
 }
コード例 #3
0
 private void registerKey(NavBarKeyboardCommand cmd) {
   myPanel.registerKeyboardAction(this, cmd.name(), cmd.getKeyStroke(), JComponent.WHEN_FOCUSED);
 }