two combo box listeners

i have two combo boxes and a text box.

combobox A has a listener and decides the contents of the combo box B. Combo Box B has a listener

and has an action to set the text box based on the selected item.

When i just have the listener on the combo box A everything works fine. but i throw in the listener for

combo box B, the action gets messed up for combo box A where i see empty dropdowns in B the first time and then

it corrects itself

A = new SteppedComboBox(PTerms)

B = new SteppedComboBox(GTerms)

C = new JTextArea();

A.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

{

Object o = e.getSource();

if (o == A)

{

try

{

B.removeAllItems();

List GTerms = getGTerms();

Iterator GTermsListIter = GTerms.iterator();

while(GTermsListIter.hasNext())

{

B.addItem((String)GTermsListIter.next());

B.setVisible(true);

}

}

catch(Exception ex)

{

}

}

}

}

});

B.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent evt){

{

Object obj = evt.getSource();

if (obj == B)

{

try

{

String Description = getDesc();

C.setText(Description);

}

catch(Exception ex)

{

}

}

}

}

});

Any help would be great...

[1481 byte] By [Mickey123a] at [2007-10-3 4:18:07]
# 1

Use the "Code" formatting button when posting code so the code is readable.

> i have two combo boxes and a text box.

Whats a text box? I'm not familiar with that component.

>A = new SteppedComboBox(PTerms)

> B = new SteppedComboBox(GTerms)

> C = new JTextArea();

Use proper variable name

a) Upper cased names indicate classes, lower cased name are for variables

b) the name should also be descriptive. You many know what "a, b and c" are now, but wait until you need to change the code in a month or two.

> Any help would be great...

Here is some code that may, or may not help:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=688505

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.

camickra at 2007-7-14 22:19:44 > top of Java-index,Desktop,Core GUI APIs...