Updating list of jComboBox with a JTextField and JButton

Hi

I have an uneditable jCombobox

When I select an item listed on the combobox, the system prints out the name of the item chosen :

jComboBox1.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

input=(String) jComboBox1.getSelectedItem();

System.out.println("Input"+input);

}

});

I would like to update the list of item by entering an item name in a text field and clicking on a JButton.

Typically :

void jAddButton_mouseClicked(MouseEvent e) {

jComboBox1.removeAllItems();

// followed by code re-adding items to combobox

System.out.println("jcombobox updated");

}

However, whenever I click on the "Add" Button, I would like to avoid having the system printing out the name of the "Input". This happens because I modify the Combo box and therefore the action listener fires ...

What is the trick ?

Thanks for your help.

[970 byte] By [ss075a] at [2007-10-3 5:21:45]
# 1
a) remove the comboBox ActionListenerb) update the comboBoxc) add the comboBox ActionListener
camickra at 2007-7-14 23:28:43 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks This was quick and simple!
ss075a at 2007-7-14 23:28:43 > top of Java-index,Desktop,Core GUI APIs...