javax.swing.JTabbedPane.setFocusTraversalKeys()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中javax.swing.JTabbedPane.setFocusTraversalKeys()方法的一些代码示例,展示了JTabbedPane.setFocusTraversalKeys()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTabbedPane.setFocusTraversalKeys()方法的具体详情如下:
包路径:javax.swing.JTabbedPane
类名称:JTabbedPane
方法名:setFocusTraversalKeys

JTabbedPane.setFocusTraversalKeys介绍

暂无

代码示例

代码示例来源:origin: ron190/jsql-injection

/**
 * 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");
}

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

private static void setupTabTraversalKeys(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<AWTKeyStroke>(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<AWTKeyStroke>(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");
}

代码示例来源:origin: stackoverflow.com

tp.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.<AWTKeyStroke>emptySet());

相关文章

JTabbedPane类方法