Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Advanced-java] JComboBox and ActionListener
- From: Christian.Ribeaud@xxxxxxxxxxxx (Christian Ribeaud)
- Subject: [Advanced-java] JComboBox and ActionListener
- Date: Wed, 23 Jan 2002 14:15:34 +0100
Hi,
I have been having problems with the following code:
...
public static class MyJComboBox extends JComboBox {
public MyJComboBox(String[] s) {
super(s);
}
public void setAllItems(String[] s) {
removeAllItems();
for (int i = 0; i < s.length; i++) {
addItem(s[i]);
}
}
}
comboBoxField = new MyJComboBox(new String[]{});
comboBoxField.addActionListener(new ComboBoxAction());
private class ComboBoxAction extends AbstractAction{
public void actionPerformed(ActionEvent ae){
fireComboBoxEvent();
}
}
protected void fireComboBoxEvent(){
MyEvent me = new MyEvent(MyJTextField1.getText(),
MyJTextField2.getText(),
(String)comboBoxField.getSelectedItem(),
this,
MyEvent.COMBOBOX,
attemptCount);
sendMyEvent(me);
}
...
The event for the JComboBox does not seem to be fired. I registered an
ActionListener
the same way for two JTextField and that works. The JComboBox's event
should be fired
everytime the user changes the selected item. I would be very grateful
if someone could
help me. Thanks and have a nice day,
christian
- Follow-Ups:
- [Advanced-java] JComboBox and ActionListener
- From: Sybille Breunig
- [Advanced-java] JComboBox and ActionListener
- Prev by Date: [Advanced-java] RMI and threading
- Next by Date: [Advanced-java] JComboBox and ActionListener
- Previous by thread: [Advanced-java] RMI and threading
- Next by thread: [Advanced-java] JComboBox and ActionListener
- Index(es):