Java tutorial
//package com.java2s; import java.awt.AWTKeyStroke; import java.util.HashSet; import java.util.Set; import javax.swing.JComponent; import javax.swing.KeyStroke; public class Main { public static void setComponentTraversalKeys(int direction, JComponent component, KeyStroke stroke) { Set<AWTKeyStroke> forwardKeys = component.getFocusTraversalKeys(direction); Set<AWTKeyStroke> newForwardKeys = new HashSet<AWTKeyStroke>(forwardKeys); newForwardKeys.add(stroke); component.setFocusTraversalKeys(direction, newForwardKeys); } }