コード例 #1
0
ファイル: HavenPanel.java プロジェクト: ProPuke/hafen-client
 void dispatch() {
   synchronized (events) {
     if (mousemv != null) {
       mousepos = new Coord(mousemv.getX(), mousemv.getY());
       ui.mousemove(mousemv, mousepos);
       mousemv = null;
     }
     InputEvent e = null;
     while ((e = events.poll()) != null) {
       if (e instanceof MouseEvent) {
         MouseEvent me = (MouseEvent) e;
         if (me.getID() == MouseEvent.MOUSE_PRESSED) {
           ui.mousedown(me, new Coord(me.getX(), me.getY()), me.getButton());
         } else if (me.getID() == MouseEvent.MOUSE_RELEASED) {
           ui.mouseup(me, new Coord(me.getX(), me.getY()), me.getButton());
         } else if (me instanceof MouseWheelEvent) {
           ui.mousewheel(
               me, new Coord(me.getX(), me.getY()), ((MouseWheelEvent) me).getWheelRotation());
         }
       } else if (e instanceof KeyEvent) {
         KeyEvent ke = (KeyEvent) e;
         if (ke.getID() == KeyEvent.KEY_PRESSED) {
           ui.keydown(ke);
         } else if (ke.getID() == KeyEvent.KEY_RELEASED) {
           ui.keyup(ke);
         } else if (ke.getID() == KeyEvent.KEY_TYPED) {
           ui.type(ke);
         }
       }
       ui.lastevent = System.currentTimeMillis();
     }
   }
 }
コード例 #2
0
ファイル: Teste.java プロジェクト: mhadaniya/3cop005
 public void keyPressed(KeyEvent key) {
   switch (key.getKeyChar()) {
     case KeyEvent.VK_ESCAPE:
       System.exit(0);
       break;
   }
 }