use of java.awt.AWTKeyStroke in project jsql-injection by ron190.
the class ActionHandler method addShortcut.
/**
* Add action to a single tabbedpane (ctrl-tab, ctrl-shift-tab).
*/
public static void addShortcut(JTabbedPane tabbedPane) {
KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl TAB");
KeyStroke ctrlShiftTab = KeyStroke.getKeyStroke("ctrl shift TAB");
// Remove ctrl-tab from normal focus traversal
Set<AWTKeyStroke> forwardKeys = new HashSet<>(tabbedPane.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
forwardKeys.remove(ctrlTab);
tabbedPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys);
// Remove ctrl-shift-tab from normal focus traversal
Set<AWTKeyStroke> backwardKeys = new HashSet<>(tabbedPane.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
backwardKeys.remove(ctrlShiftTab);
tabbedPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardKeys);
// Add keys to the tab's input map
InputMap inputMap = tabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(ctrlTab, "navigateNext");
inputMap.put(ctrlShiftTab, "navigatePrevious");
}
use of java.awt.AWTKeyStroke in project sulky by huxi.
the class SwingLogging method logTraversal.
public static void logTraversal(JComponent component) {
final Logger logger = LoggerFactory.getLogger(SwingLogging.class);
final int[] ids = { KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS };
final String[] names = { "FORWARD_TRAVERSAL_KEYS", "BACKWARD_TRAVERSAL_KEYS", "UP_CYCLE_TRAVERSAL_KEYS", "DOWN_CYCLE_TRAVERSAL_KEYS" };
if (logger.isDebugEnabled()) {
for (int i = 0; i < ids.length; i++) {
Set<AWTKeyStroke> keys = component.getFocusTraversalKeys(ids[i]);
logger.debug("ID: {}\nKeys:{}", names[i], keys);
}
}
}
Aggregations