Java 8 KeyboardFocusManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 KeyboardFocusManager class.

This code example shows how to use the following methods:setCurrentKeyboardFocusManager
 
        frameButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    // Right before the dialog will be shown, there will be called 
                    // enqueuKeyEvents() method. We are to catch it. 
                    KeyboardFocusManager.setCurrentKeyboardFocusManager(testKFM);
                    dialog.setVisible(true);
                    KeyboardFocusManager.setCurrentKeyboardFocusManager(defKFM);
                } 
            }); 
 
        Runnable showAction = new Runnable() {
            public void run() { 
                frame.setVisible(true);
            } 
        }; 
        if (!Util.trackFocusGained(frameButton, showAction, 2000, false)) {
            System.out.println("Test error: wrong initial focus!");
            return; 
        } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addKeyEventDispatcher
    protected static boolean SHOULD_BREAK_EVENT_DISPATCHING = false;
     
    public KeyMemoryEventDispatcher(Component source){
        src = source;
        manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        manager.addKeyEventDispatcher(this);        
        holdKeys = new ArrayList<Character>();
        listeners = new ArrayList<KeyListener>();
    } 
     
    @Override 
    public boolean dispatchKeyEvent(KeyEvent e) {
        manager.redispatchEvent(src, e);
        handleEvent(e);
        //System.out.println( holdKeys.toString()); 
        return SHOULD_BREAK_EVENT_DISPATCHING;
    } 
     
    protected void handleEvent(KeyEvent e){
        int id = e.getID();
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:dispatchEvent
paramKeyEvent.consume();
            char c2 = ((String)this.trans.get(str)).charAt(0);
            this.cont.MyLog("Translate to: " + c2);
            this.prev_c = ' ';
            this.man.dispatchEvent(new KeyEvent(paramKeyEvent.getComponent(), 401, System.currentTimeMillis(), 0, 8, (char) 65535));
            this.man.dispatchEvent(new KeyEvent(paramKeyEvent.getComponent(), 400, System.currentTimeMillis(), 0, 0, '\b'));
            this.man.dispatchEvent(new KeyEvent(paramKeyEvent.getComponent(), 402, System.currentTimeMillis(), 0, 8, (char) 65535));
            this.man.dispatchEvent(new KeyEvent(paramKeyEvent.getComponent(), 400, System.currentTimeMillis(), 0, 0, c2));
            return true; 
          } 
          this.prev_c = c1;
        } 
        return false; 
      } 
      if ((paramKeyEvent.getKeyCode() == 16) && (paramKeyEvent.getID() == 401))
      { 
        this.ShiftEvent = paramKeyEvent;
        this.ShiftConsumed = true;
        return true; 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 KeyboardFocusManager Methods: