< prev index next >

src/java.desktop/share/classes/javax/swing/KeyboardManager.java

Print this page




 190              containerMap.remove(topContainer);  // remove table to enable GC
 191              //System.out.println("removed a container");
 192          }
 193 
 194          componentKeyStrokeMap.remove(ckp);
 195 
 196          // Check for EmbeddedFrame case, they know how to process accelerators even
 197          // when focus is not in Java
 198          if (topContainer instanceof EmbeddedFrame) {
 199              ((EmbeddedFrame)topContainer).unregisterAccelerator(ks);
 200          }
 201      }
 202 
 203     /**
 204       * This method is called when the focused component (and none of
 205       * its ancestors) want the key event.  This will look up the keystroke
 206       * to see if any chidren (or subchildren) of the specified container
 207       * want a crack at the event.
 208       * If one of them wants it, then it will "DO-THE-RIGHT-THING"
 209       */

 210     public boolean fireKeyboardAction(KeyEvent e, boolean pressed, Container topAncestor) {
 211 
 212          if (e.isConsumed()) {
 213               System.out.println("Acquired pre-used event!");
 214               Thread.dumpStack();
 215          }
 216 
 217          // There may be two keystrokes associated with a low-level key event;
 218          // in this case a keystroke made of an extended key code has a priority.
 219          KeyStroke ks;
 220          KeyStroke ksE = null;
 221 
 222 
 223          if(e.getID() == KeyEvent.KEY_TYPED) {
 224                ks=KeyStroke.getKeyStroke(e.getKeyChar());
 225          } else {
 226                if(e.getKeyCode() != e.getExtendedKeyCode()) {
 227                    ksE=KeyStroke.getKeyStroke(e.getExtendedKeyCode(), e.getModifiers(), !pressed);
 228                }
 229                ks=KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), !pressed);




 190              containerMap.remove(topContainer);  // remove table to enable GC
 191              //System.out.println("removed a container");
 192          }
 193 
 194          componentKeyStrokeMap.remove(ckp);
 195 
 196          // Check for EmbeddedFrame case, they know how to process accelerators even
 197          // when focus is not in Java
 198          if (topContainer instanceof EmbeddedFrame) {
 199              ((EmbeddedFrame)topContainer).unregisterAccelerator(ks);
 200          }
 201      }
 202 
 203     /**
 204       * This method is called when the focused component (and none of
 205       * its ancestors) want the key event.  This will look up the keystroke
 206       * to see if any chidren (or subchildren) of the specified container
 207       * want a crack at the event.
 208       * If one of them wants it, then it will "DO-THE-RIGHT-THING"
 209       */
 210     @SuppressWarnings("deprecation")
 211     public boolean fireKeyboardAction(KeyEvent e, boolean pressed, Container topAncestor) {
 212 
 213          if (e.isConsumed()) {
 214               System.out.println("Acquired pre-used event!");
 215               Thread.dumpStack();
 216          }
 217 
 218          // There may be two keystrokes associated with a low-level key event;
 219          // in this case a keystroke made of an extended key code has a priority.
 220          KeyStroke ks;
 221          KeyStroke ksE = null;
 222 
 223 
 224          if(e.getID() == KeyEvent.KEY_TYPED) {
 225                ks=KeyStroke.getKeyStroke(e.getKeyChar());
 226          } else {
 227                if(e.getKeyCode() != e.getExtendedKeyCode()) {
 228                    ksE=KeyStroke.getKeyStroke(e.getExtendedKeyCode(), e.getModifiers(), !pressed);
 229                }
 230                ks=KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), !pressed);


< prev index next >