Example usage for java.awt KeyboardFocusManager getDefaultFocusTraversalKeys

List of usage examples for java.awt KeyboardFocusManager getDefaultFocusTraversalKeys

Introduction

In this page you can find the example usage for java.awt KeyboardFocusManager getDefaultFocusTraversalKeys.

Prototype

public Set<AWTKeyStroke> getDefaultFocusTraversalKeys(int id) 

Source Link

Document

Returns a Set of default focus traversal keys for a given traversal operation.

Usage

From source file:Main.java

/**
 * Adds the focus forward key./*from ww  w  .j  a va  2  s  . com*/
 *
 * @param button
 *            the button
 */
public static void addFocusForwardKey(final int button) {
    final KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    final Set<?> forwardKeys = manager
            .getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    final Set<KeyStroke> newForwardKeys = new HashSet(forwardKeys);
    newForwardKeys.add(KeyStroke.getKeyStroke(button, 0));
    manager.setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newForwardKeys);
}