I was referring to the function keys such as F1, F2, F3 etc. I would also
like to use JButtons external to the JTabbed pane to switch between tabs
too. Any ideas?
> I was referring to the function keys such as F1, F2, F3 etc. I would also
> like to use JButtons external to the JTabbed pane to switch between tabs
> too. Any ideas?
For the function keys, you will need to map the Keystroke to the tab that
you want to select. For this, I would use a java.util.Map.
For buttons, I would use a "client property" on the button that would
indicate what tab to switch to. Then you could use a single Action for
all of the buttons. It would get the client property from the source of
the event and use that to switch the tabs.

Signature
Regards,
John McGrath
ninhoa@yahoo.es - 16 Mar 2005 15:17 GMT
Add a KeyListener to your JTabbedPane and then (for example with 2 tabs):
if (e.getKeyCode()==KeyEvent.VK_F1)
getJTabbedPane().setSelectedIndex(0);
else if (e.getKeyCode()==KeyEvent.VK_F2)
getJTabbedPane().setSelectedIndex(1);
or setSelectedComponent(Component c)
Charley Liu - 20 Mar 2005 13:25 GMT
Thanks, that was exactly what I needed to know =)