If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

associate a JComboBox to JTabbedPane component

Hi guys;
in my java program i'm trying to implement the following functionality :

I have a JTabbedPane to which i'm adding components dynamically (at runtime).
I have a JComboBox that i want to associate each time to the JTabbedPane selected component:
i.e. each time i select a component i want to fill the comboBox with items that are related to this selected JTabbedPane component.

oops !
guys : i'm still having a little problem...here is the description:

when i create a new panel and add it to tabbedpane i register a changeListener on tabbedPane. the stateChange() method calls a method fill() which removes old values of combobox and fill it with new ones. In fill() method i add an ActionListener to comboBox which gets the selected element and do some work...
now the problem is that when i select an elemt this fires a changeState for the tabbedPane which in turn refills the comboBox and the combo text is always the first element of the combobox...
this problem is probably because the events on combo and tabbedPane are related.
How can i fix this ?

This is a well knows situation but, it is difficult to tell exactly what this is without your code. You may have wired the listeners and callbacks wrong.
Here is my modified example, but I fail to see a behavious like you mention.