Example usage for java.awt KeyboardFocusManager setDefaultFocusTraversalKeys

List of usage examples for java.awt KeyboardFocusManager setDefaultFocusTraversalKeys

Introduction

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

Prototype

public void setDefaultFocusTraversalKeys(int id, Set<? extends AWTKeyStroke> keystrokes) 

Source Link

Document

Sets the default focus traversal keys for a given traversal operation.

Usage

From source file:Main.java

/**
 * Adds the focus forward key.//from w ww  . ja va  2  s.  c  om
 *
 * @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);
}