I have two Jtables Emplyoee and Manager.If I enter on Emplyoee Table then focus should go on Manager table.I used ChangeSelection but it is not working.
Asked
Active
Viewed 86 times
0
-
selection != focus. Anyway, your question and what you tried is unclear - please show an SSCCE to explain what exactly you want to achieve – kleopatra Jun 23 '13 at 13:37
1 Answers
1
The simplest solution I can think of is to attach a key binding to the Employee
table that moves focus to the Manager
Take a look at Key Bindings for more details.
Within your action handler, you would need to call requestFocusInWindow
using a instance of the Manager
table.
I did look at the focus sub system, but this would effect the entire focus root, which I felt was beyond the scope of what you were asking.
Updated
You could change the focus traversal keys, but this will only move focus to the next focusable component...
Set forward = new HashSet(table.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
forward.add(KeyStroke.getKeyStroke("ENTER"));
table.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forward);
//Set backward = new HashSet(table.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
//backward.add(KeyStroke.getKeyStroke("shift TAB"));
//table.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backward);

MadProgrammer
- 343,457
- 22
- 230
- 366