所以基本上您想更改Tab上的JTable
功能?
Swing使用键绑定
简单地替换现有的功能Swing组件在按键等添加一个新的键绑定
到JTable
(美丽的发生是因为JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
):
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tab");
table.getActionMap().put("tab", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
//do something on JTable tab pressed or do nothing
}
});
请尝试table_name. set焦点(false);