Java Swing Tutorial - Java KeyboardFocusManager BACKWARD_TRAVERSAL_KEYS








Syntax

KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS has the following syntax.

public static final int BACKWARD_TRAVERSAL_KEYS

Example

In the following code shows how to use KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS field.

import java.awt.AWTKeyStroke;
import java.awt.KeyboardFocusManager;
import java.util.HashSet;
import java.util.Set;
//from w  ww  . j a  v a  2  s .  c  om
import javax.swing.KeyStroke;

public class Main {
  public static void main(String[] argv) throws Exception {
    Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(KeyboardFocusManager
        .getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(
            KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));

    set.add(KeyStroke.getKeyStroke("F3"));
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);

  }
}