本文整理了Java中javax.swing.JComboBox.setFocusTraversalKeysEnabled()
方法的一些代码示例,展示了JComboBox.setFocusTraversalKeysEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.setFocusTraversalKeysEnabled()
方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称:JComboBox
方法名:setFocusTraversalKeysEnabled
暂无
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
private void initTabHandler() {
this.combo.setFocusTraversalKeysEnabled(false);
this.combo.getActionMap().put("tab-action", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
combo.setSelectedItem(getText());
Component component = getParent().getParent();
if(component instanceof JTable) {
JTable table = (JTable)component;
if((e.getModifiers() & ActionEvent.SHIFT_MASK) > 0) {
table.changeSelection(table.getEditingRow(), table.getEditingColumn()-1, false, false);
} else {
table.changeSelection(table.getEditingRow(), table.getEditingColumn()+1, false, false);
}
} else {
if((e.getModifiers() & ActionEvent.SHIFT_MASK) > 0) {
transferFocusBackward();
} else {
transferFocus();
}
}
}
});
InputMap inputMap = this.combo.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke("TAB"), "tab-action");
inputMap.put(KeyStroke.getKeyStroke("shift TAB"), "tab-action");
}
代码示例来源:origin: stackoverflow.com
final JComboBox simpleBox = new JComboBox(Locale.getAvailableLocales());
// this line configures the combo to only commit on ENTER
// or selecting an item from the list
simpleBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
//
// simpleBox.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
// Collections.EMPTY_SET);
// just noticed the OPs edit - following indeed is easier to disable _all_ traversal
// keys with one statement
simpleBox.setFocusTraversalKeysEnabled(false);
Action myAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
LOG.info("got it!");
simpleBox.transferFocus();
}
};
simpleBox.getActionMap().put("tab-action", myAction);
simpleBox.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.put(KeyStroke.getKeyStroke("TAB"), "tab-action");
内容来源于网络,如有侵权,请联系作者删除!