Java Code Examples for java.awt.AWTKeyStroke#getAWTKeyStrokeForEvent()

The following examples show how to use java.awt.AWTKeyStroke#getAWTKeyStrokeForEvent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputContext.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 2
Source File: InputContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 3
Source File: InputContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 4
Source File: InputContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 5
Source File: InputContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 6
Source File: InputContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 7
Source File: InputContext.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 8
Source File: InputContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 9
Source File: InputContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 10
Source File: InputContext.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 11
Source File: InputContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 12
Source File: InputContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the key event is the input method selection key or not.
 */
private boolean checkInputMethodSelectionKey(KeyEvent event) {
    if (inputMethodSelectionKey != null) {
        AWTKeyStroke aKeyStroke = AWTKeyStroke.getAWTKeyStrokeForEvent(event);
        return inputMethodSelectionKey.equals(aKeyStroke);
    } else {
        return false;
    }
}
 
Example 13
Source File: EmbeddedFrame.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Need this method to detect when the focus may have chance to leave the
 * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
 * from DefaultKeyboardFocusManager.processKeyEvent with some minor
 * modifications.
 */
public boolean dispatchKeyEvent(KeyEvent e) {

    Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
                                .getCurrentFocusCycleRoot();

    // if we are not in EmbeddedFrame's cycle, we should not try to leave.
    if (this != currentRoot) {
        return false;
    }

    // KEY_TYPED events cannot be focus traversal keys
    if (e.getID() == KeyEvent.KEY_TYPED) {
        return false;
    }

    if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
        return false;
    }

    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    Set<AWTKeyStroke> toTest;
    Component currentFocused = e.getComponent();

    toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component last = getFocusTraversalPolicy().getLastComponent(this);
        if (currentFocused == last || last == null) {
            if (traverseOut(FORWARD)) {
                e.consume();
                return true;
            }
        }
    }

    toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component first = getFocusTraversalPolicy().getFirstComponent(this);
        if (currentFocused == first || first == null) {
            if (traverseOut(BACKWARD)) {
                e.consume();
                return true;
            }
        }
    }
    return false;
}
 
Example 14
Source File: EmbeddedFrame.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Need this method to detect when the focus may have chance to leave the
 * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
 * from DefaultKeyboardFocusManager.processKeyEvent with some minor
 * modifications.
 */
public boolean dispatchKeyEvent(KeyEvent e) {

    Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
                                .getCurrentFocusCycleRoot();

    // if we are not in EmbeddedFrame's cycle, we should not try to leave.
    if (this != currentRoot) {
        return false;
    }

    // KEY_TYPED events cannot be focus traversal keys
    if (e.getID() == KeyEvent.KEY_TYPED) {
        return false;
    }

    if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
        return false;
    }

    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    Set<AWTKeyStroke> toTest;
    Component currentFocused = e.getComponent();

    toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component last = getFocusTraversalPolicy().getLastComponent(this);
        if (currentFocused == last || last == null) {
            if (traverseOut(FORWARD)) {
                e.consume();
                return true;
            }
        }
    }

    toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component first = getFocusTraversalPolicy().getFirstComponent(this);
        if (currentFocused == first || first == null) {
            if (traverseOut(BACKWARD)) {
                e.consume();
                return true;
            }
        }
    }
    return false;
}
 
Example 15
Source File: EmbeddedFrame.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Need this method to detect when the focus may have chance to leave the
 * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
 * from DefaultKeyboardFocusManager.processKeyEvent with some minor
 * modifications.
 */
public boolean dispatchKeyEvent(KeyEvent e) {

    Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
                                .getCurrentFocusCycleRoot();

    // if we are not in EmbeddedFrame's cycle, we should not try to leave.
    if (this != currentRoot) {
        return false;
    }

    // KEY_TYPED events cannot be focus traversal keys
    if (e.getID() == KeyEvent.KEY_TYPED) {
        return false;
    }

    if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
        return false;
    }

    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    Set<AWTKeyStroke> toTest;
    Component currentFocused = e.getComponent();

    toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component last = getFocusTraversalPolicy().getLastComponent(this);
        if (currentFocused == last || last == null) {
            if (traverseOut(FORWARD)) {
                e.consume();
                return true;
            }
        }
    }

    toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component first = getFocusTraversalPolicy().getFirstComponent(this);
        if (currentFocused == first || first == null) {
            if (traverseOut(BACKWARD)) {
                e.consume();
                return true;
            }
        }
    }
    return false;
}
 
Example 16
Source File: EmbeddedFrame.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Need this method to detect when the focus may have chance to leave the
 * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
 * from DefaultKeyboardFocusManager.processKeyEvent with some minor
 * modifications.
 */
public boolean dispatchKeyEvent(KeyEvent e) {

    Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
                                .getCurrentFocusCycleRoot();

    // if we are not in EmbeddedFrame's cycle, we should not try to leave.
    if (this != currentRoot) {
        return false;
    }

    // KEY_TYPED events cannot be focus traversal keys
    if (e.getID() == KeyEvent.KEY_TYPED) {
        return false;
    }

    if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
        return false;
    }

    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    Set<AWTKeyStroke> toTest;
    Component currentFocused = e.getComponent();

    toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component last = getFocusTraversalPolicy().getLastComponent(this);
        if (currentFocused == last || last == null) {
            if (traverseOut(FORWARD)) {
                e.consume();
                return true;
            }
        }
    }

    toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component first = getFocusTraversalPolicy().getFirstComponent(this);
        if (currentFocused == first || first == null) {
            if (traverseOut(BACKWARD)) {
                e.consume();
                return true;
            }
        }
    }
    return false;
}
 
Example 17
Source File: EmbeddedFrame.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Need this method to detect when the focus may have chance to leave the
 * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
 * from DefaultKeyboardFocusManager.processKeyEvent with some minor
 * modifications.
 */
public boolean dispatchKeyEvent(KeyEvent e) {

    Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
                                .getCurrentFocusCycleRoot();

    // if we are not in EmbeddedFrame's cycle, we should not try to leave.
    if (this != currentRoot) {
        return false;
    }

    // KEY_TYPED events cannot be focus traversal keys
    if (e.getID() == KeyEvent.KEY_TYPED) {
        return false;
    }

    if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
        return false;
    }

    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    Set<AWTKeyStroke> toTest;
    Component currentFocused = e.getComponent();

    toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component last = getFocusTraversalPolicy().getLastComponent(this);
        if (currentFocused == last || last == null) {
            if (traverseOut(FORWARD)) {
                e.consume();
                return true;
            }
        }
    }

    toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component first = getFocusTraversalPolicy().getFirstComponent(this);
        if (currentFocused == first || first == null) {
            if (traverseOut(BACKWARD)) {
                e.consume();
                return true;
            }
        }
    }
    return false;
}
 
Example 18
Source File: EmbeddedFrame.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Need this method to detect when the focus may have chance to leave the
 * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
 * from DefaultKeyboardFocusManager.processKeyEvent with some minor
 * modifications.
 */
public boolean dispatchKeyEvent(KeyEvent e) {

    Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
                                .getCurrentFocusCycleRoot();

    // if we are not in EmbeddedFrame's cycle, we should not try to leave.
    if (this != currentRoot) {
        return false;
    }

    // KEY_TYPED events cannot be focus traversal keys
    if (e.getID() == KeyEvent.KEY_TYPED) {
        return false;
    }

    if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
        return false;
    }

    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    Set<AWTKeyStroke> toTest;
    Component currentFocused = e.getComponent();

    toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component last = getFocusTraversalPolicy().getLastComponent(this);
        if (currentFocused == last || last == null) {
            if (traverseOut(FORWARD)) {
                e.consume();
                return true;
            }
        }
    }

    toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component first = getFocusTraversalPolicy().getFirstComponent(this);
        if (currentFocused == first || first == null) {
            if (traverseOut(BACKWARD)) {
                e.consume();
                return true;
            }
        }
    }
    return false;
}
 
Example 19
Source File: EmbeddedFrame.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Need this method to detect when the focus may have chance to leave the
 * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
 * from DefaultKeyboardFocusManager.processKeyEvent with some minor
 * modifications.
 */
public boolean dispatchKeyEvent(KeyEvent e) {

    Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
                                .getCurrentFocusCycleRoot();

    // if we are not in EmbeddedFrame's cycle, we should not try to leave.
    if (this != currentRoot) {
        return false;
    }

    // KEY_TYPED events cannot be focus traversal keys
    if (e.getID() == KeyEvent.KEY_TYPED) {
        return false;
    }

    if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
        return false;
    }

    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    Set<AWTKeyStroke> toTest;
    Component currentFocused = e.getComponent();

    toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component last = getFocusTraversalPolicy().getLastComponent(this);
        if (currentFocused == last || last == null) {
            if (traverseOut(FORWARD)) {
                e.consume();
                return true;
            }
        }
    }

    toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component first = getFocusTraversalPolicy().getFirstComponent(this);
        if (currentFocused == first || first == null) {
            if (traverseOut(BACKWARD)) {
                e.consume();
                return true;
            }
        }
    }
    return false;
}
 
Example 20
Source File: EmbeddedFrame.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Need this method to detect when the focus may have chance to leave the
 * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
 * from DefaultKeyboardFocusManager.processKeyEvent with some minor
 * modifications.
 */
public boolean dispatchKeyEvent(KeyEvent e) {

    Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
                                .getCurrentFocusCycleRoot();

    // if we are not in EmbeddedFrame's cycle, we should not try to leave.
    if (this != currentRoot) {
        return false;
    }

    // KEY_TYPED events cannot be focus traversal keys
    if (e.getID() == KeyEvent.KEY_TYPED) {
        return false;
    }

    if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
        return false;
    }

    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    Set<AWTKeyStroke> toTest;
    Component currentFocused = e.getComponent();

    toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component last = getFocusTraversalPolicy().getLastComponent(this);
        if (currentFocused == last || last == null) {
            if (traverseOut(FORWARD)) {
                e.consume();
                return true;
            }
        }
    }

    toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
    if (toTest.contains(stroke)) {
        // 6581899: performance improvement for SortingFocusTraversalPolicy
        Component first = getFocusTraversalPolicy().getFirstComponent(this);
        if (currentFocused == first || first == null) {
            if (traverseOut(BACKWARD)) {
                e.consume();
                return true;
            }
        }
    }
    return false;
}