Got some trouble with JComboBox
I have some code like this:
int i ;
for( i = 0 ; i < jComboBox1.getItemCount(); i++)
{
if(jComboBox1.getSelectedIndex() == i)
{
jComboBox2.addItem(jComboBox1.getSelectedItem());
}
}
int index = jComboBox1.getSelectedIndex();
jComboBox1.removeItemAt(index);
I have 2 comboBox , first have 3 items , second have nothing.
I want : when we choose any item of First ComboBox, it will auto add to Second ComboBox,and then, the item we choose in First Box will auto remove.
And i got some trouble:
.First is : when the item from First Box auto add to Second Box, it auto add 2 same item .
.Second is : when i try to remove the item that we choose, it will remove all item from the item we choose to the last item.
Can you guys help me? Or tell me what i'm wrong! Thanks!!