Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Advanced-java] JComboBox and ActionListener
- From: sbr@xxxxxxxxxxx (Sybille Breunig)
- Subject: [Advanced-java] JComboBox and ActionListener
- Date: Wed, 23 Jan 2002 14:31:48 +0100
Try the ItemListener
Hope this helps
Sybille
----- Original Message -----
From: "Christian Ribeaud" <Christian.Ribeaud@xxxxxxxxxxxx>
To: <advanced-java@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, January 23, 2002 2:15 PM
Subject: [Advanced-java] JComboBox and ActionListener
> 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
> _______________________________________________
> Advanced-java mailing list
> Advanced-java@xxxxxxxxxxxxxxxxxxxxxx
> http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java
>
- Follow-Ups:
- [Advanced-java] JComboBox and ActionListener
- From: Christian Ribeaud
- [Advanced-java] JComboBox and ActionListener
- References:
- [Advanced-java] JComboBox and ActionListener
- From: Christian Ribeaud
- [Advanced-java] JComboBox and ActionListener
- Prev by Date: [Advanced-java] JComboBox and ActionListener
- Next by Date: [Advanced-java] JComboBox and ActionListener
- Previous by thread: [Advanced-java] JComboBox and ActionListener
- Next by thread: [Advanced-java] JComboBox and ActionListener
- Index(es):