I have a JTabbedPane and have three JPanels forming the three tabs. I need
to set the default button on one or other Panel depending which one is
active / showing at the time.
How do I do this ? I need to toggle the default buttons on the panels
but I need to know which panel is currently showing. Do I detect the
active panel using a listener on both Panel classes or can I detect
something and set it in the JTabbedPanel ??
Torgil - 04 Jan 2005 18:15 GMT
> I have a JTabbedPane and have three JPanels forming the three tabs. I need
> to set the default button on one or other Panel depending which one is
[quoted text clipped - 7 lines]
> --
> Message posted via http://www.javakb.com
You can add a ChangeListener to the JTabbedPane. The ChangeListener
will get notified whenever the selected tab changes; the JTabbedPane
itself will be the source of the ChangeEvent, and then you can call
getSelectedComponent or getSelectedIndex to see what is currently
showing.
Cheers,
- Torgil
Christian Kaufhold - 07 Jan 2005 16:33 GMT
> I have a JTabbedPane and have three JPanels forming the three tabs. I need
> to set the default button on one or other Panel depending which one is
[quoted text clipped - 4 lines]
> active panel using a listener on both Panel classes or can I detect
> something and set it in the JTabbedPanel ??
Ancestor- or HierarchyListener (to be JTabbedPane-independent).
Christian