e611. Setting Focus Traversal Keys for the Entire Application

Posted borter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了e611. Setting Focus Traversal Keys for the Entire Application相关的知识,希望对你有一定的参考价值。

This example changes the focus traversal keys for the entire application. For an example of how to change the focus traversal keys for a particular component, see e610 Setting Focus Traversal Keys in a Component.

    // Change the forward focus traversal keys for the application
    Set set = new HashSet(
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(
            KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
    set.clear();   // Call clear() if you want to eliminate the current key set
    set.add(KeyStroke.getKeyStroke("F2"));
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
    
    // Change the backward focus traversal keys for the application
    set = new HashSet(
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(
            KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
    set.clear();   // Call clear() if you want to eliminate the current key set
    set.add(KeyStroke.getKeyStroke("F3"));
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);
    
    // Remove all forward and backward focus traversal keys for the application
    set.clear();
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);

 

Related Examples

以上是关于e611. Setting Focus Traversal Keys for the Entire Application的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #611 (Div. 3) E

Codeforces Round #611 (Div. 3) E - New Year Parties (贪心)

codeforces Round #611

e613. Modifying the Focus Traversal Order

e621. Activating a Keystroke When Any Child Component Has Focus

e606. Determining Which Component or Window Has the Focus