Ejemplo n.º 1
0
 @Override
 public void keyPressed(KeyEvent ke) {
   if (this.isFocused()) {
     switch (ke.getKeyCode()) {
       case KeyEvent.VK_UP:
         if (keyPressed != KeyEvent.VK_UP) {
           keyPressed = KeyEvent.VK_UP;
           client.getNetworkThread().send(ClientCommand.UP);
         }
         break;
       case KeyEvent.VK_DOWN:
         if (keyPressed != KeyEvent.VK_DOWN) {
           keyPressed = KeyEvent.VK_DOWN;
           client.getNetworkThread().send(ClientCommand.DOWN);
         }
         break;
     }
   }
 }
Ejemplo n.º 2
0
 @Override
 public void keyReleased(KeyEvent ke) {
   if (keyPressed == -1) return;
   keyPressed = -1;
   switch (ke.getKeyCode()) {
     case KeyEvent.VK_UP:
     case KeyEvent.VK_DOWN:
       client.getNetworkThread().send(ClientCommand.STOP);
       break;
   }
 }