Is there a way to skip focus to a particular component when we use "Tab" key. If user double clicks on the component then focus should go to that text.
So basically you want to alter JTable
functionality on Tab pressed?
Swing uses KeyBinding
s simply replace existing functionality of Swing component on keypressed etc by adding a new KeyBinding
to JTable
(the beauty happens because of 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.setFocusable(false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.