Package java.awt

Examples of java.awt.KeyEventDispatcher


        m_progBar.setFont(m_progBar.getFont().deriveFont(11.0f));

        doAddMenuBar();
        doInitTimers();

        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher()
        {
            public boolean dispatchKeyEvent(KeyEvent e)
            {
                boolean flag = false;
                if (m_bImgFullSize && e.getID() == KeyEvent.KEY_PRESSED && !e.isShiftDown() && !e.isAltDown() && !e.isAltGraphDown() && !e.isControlDown() && !e.isMetaDown())
View Full Code Here


          break;
        }
      }
    });

    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
      @Override
      public boolean dispatchKeyEvent(KeyEvent e) {
        int mod = e.getModifiers();
        if(mod != KEYMASK)
          return false;
View Full Code Here

    cancel.setMnemonic('c');
   
    kbf = KeyboardFocusManager.
    getCurrentKeyboardFocusManager();
   
    final KeyEventDispatcher EventDispatcher = new KeyEventDispatcher() {

      @Override
      public boolean dispatchKeyEvent(KeyEvent e) {
        boolean keyUsed = false;
        if(e.getID() == KeyEvent.KEY_PRESSED && e.isControlDown()){
View Full Code Here

   
    //KeyListener
    KeyboardFocusManager kbf = KeyboardFocusManager.
    getCurrentKeyboardFocusManager();
   
    final KeyEventDispatcher EventDispatcher = new KeyEventDispatcher() {

      @Override
      public boolean dispatchKeyEvent(KeyEvent e) {
        boolean keyUsed = false;
        if(e.getID() == KeyEvent.KEY_PRESSED){
View Full Code Here

        return statusBar;
    }

    private FieldGui newFieldGui(Container c, Object constraints, int guiLayout) {
        FieldGui gui = new FieldGui(guiLayout, this, c, constraints, props);
        gui.getScene().addKeyboardEventsDispatcher(new KeyEventDispatcher() {

            public boolean dispatchKeyEvent(KeyEvent e) {
                if ((e.getKeyCode() == Player._keyCodeMap.get(Player.key.ONE_start) || e.getKeyCode() == Player._keyCodeMap.get(Player.key.TWO_start) || e.getKeyCode() == KeyEvent.VK_P) && e.getID() == KeyEvent.KEY_PRESSED) {
                    pauseResumeGame();
                    return true;
View Full Code Here

  public static void setUndoRedo(boolean undoredo){
    KeyBoard.undoredo = undoredo;
  }

  private KeyBoard() {
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {

      @Override
      public boolean dispatchKeyEvent(KeyEvent e) {
        if (e.getID() == KeyEvent.KEY_RELEASED) {
          if (e.getKeyCode() == KeyEvent.VK_F3) {
View Full Code Here

     */
    public JXLoginPane(LoginService service, PasswordStore passwordStore, UserNameStore userStore, List<String> servers) {
        //init capslock detection support
        if (Boolean.parseBoolean(System.getProperty("swingx.enableCapslockTesting"))) {
            capsOnTest = new CapsOnTest();
            capsOnListener = new KeyEventDispatcher() {
                public boolean dispatchKeyEvent(KeyEvent e) {
                    if (e.getID() != KeyEvent.KEY_PRESSED) {
                        return false;
                    }
                    if (e.getKeyCode() == 20) {
View Full Code Here

        } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }

        final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        kfm.addKeyEventDispatcher(new KeyEventDispatcher() {
            @Override
            public boolean dispatchKeyEvent(KeyEvent e) {
                if (e.getID() != KeyEvent.KEY_TYPED) return false;
                if (e.getKeyChar() == 'i') printCommonDebug();
                if (e.getKeyChar() == 'p') printPropertiesDebug();
View Full Code Here

        hookKS = ks;
        initialize();
    }

    public static void initialize() {
        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
            public boolean dispatchKeyEvent(KeyEvent e) {
                KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
                if (!ks.equals(hookKS))
                    return false;
                Component root = SwingUtilities.getRootPane(e.getComponent());
View Full Code Here

  }
 
  @Test
  public void testKeyEventDispatcher() {
    JPanel p = new JPanel();
    KeyEventDispatcher d = new LocalControlKeyEventDispatcher(abstraction);
   
    Mockito.when(listener.isMouseOutsideOfPlotArea()).thenReturn(true);   
    KeyEvent ctrlDown = new KeyEvent(p, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, KeyEvent.VK_CONTROL,
        KeyEvent.CHAR_UNDEFINED);
    KeyEvent ctrlUp = new KeyEvent(p, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), 0, KeyEvent.VK_CONTROL,
        KeyEvent.CHAR_UNDEFINED);
   
    // Pressing when mouse is not over should do nothing
    d.dispatchKeyEvent(ctrlDown)
    Mockito.verifyZeroInteractions(controlManager);
   
    // Now, try it with mouse in the plot area
    Mockito.when(listener.isMouseOutsideOfPlotArea()).thenReturn(false);   
   
    // Now, it should inform the control manager of the key press
    d.dispatchKeyEvent(ctrlDown);
    Mockito.verify(controlManager, Mockito.atLeastOnce()).informKeyState(KeyEvent.VK_CONTROL, true);
    d.dispatchKeyEvent(ctrlUp);
    Mockito.verify(controlManager, Mockito.atLeastOnce()).informKeyState(KeyEvent.VK_CONTROL, false);
  }
View Full Code Here

TOP

Related Classes of java.awt.KeyEventDispatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.