I am trying to do a small things.
I have a table like this
Type1 SubType1 Temp1 SubTemp1
Type1 SubType2 Temp2 SubTemp2
I have created a frame where there are 2 comboboxes and 2 textfield
COmboBox1 wil have field 1 and combobox will have field2.
Depending on the valuess chosen in field1 the combobox2 should get updated and depending on the 2 comboboxes the textfield should get field
I have writen ItemStatehanged event, When the item state of the first combo box , first thing I do it
Combobox2.removeAllItems();, then go ahead the fill the Items of combobox2 with new values depending on combobox1 selected.
But the problem I am having is when I change the item in First combo box , the removeAllItems(); fires the event on the second box also and then it creates a problem.
I tried everything, nothing works.
Ccan anybody read the code which I am attaching and give me the solution. or if anyone has a other solution to implement this please help me.
class SymItem implements java.awt.event.ItemListener
{
public void itemStateChanged(java.awt.event.ItemEvent
event)
{
Object object = event.getSource();
if (object == JComboBox1){
JComboBox1_itemStateChanged(event);}
else if (object == JComboBox2){
JComboBox2_itemStateChanged(event);}
}
}
void JComboBox1_itemStateChange (java.awt.event.ItemEvent event)
{
JComboBox2.removeAllItems();
fillCombo2(JComboBox1.getSelectedItem().toString());
fillOther(JComboBox1.getSelectedItem().toString(),JComboBox2.getSelectedItem().toString());
}
void JComboBox2_itemStateChanged(java.awt.event.ItemEvent event)
{
fillOther(JComboBox1.getSelectedItem().toString() ,JComboBox2.getSelectedItem().toString());
}
Here fillComboBox2 , reads the database and fills the second combobox and fillOther is suppose to fill the other 2 textfields.
}
}
[This message has been edited by Milind Deodhar (edited March 28, 2001).]
[This message has been edited by Milind Deodhar (edited March 28, 2001).]