Well, a quick workaround of this is add that
ActionListener to the ComboBoxEditor, which usually is
a JTextField or something. Then it could
work. I do think now it could be a bug focus
transition
related, but no big deal anyway.
Lei
----- Original Message -----
Sent: Friday, January 03, 2003 11:11
AM
Subject: Is this a bug of 1.4.1? Anybody
has a workaround?
Looks to me a JCheckBox can not coexist with a
JComboBox?
Here is the code. Everytime you click the
JCheckBox then you will triger the
actionPerformed method of the JComboBox. I dont
know if this is a known bug
or not.
Thanks
Lei
//--------------------------------------------------------------------------------------------------------------
package com.test;
import java.awt.*;
import
java.awt.event.*;
import javax.swing.*;
public class ComboBoxTest {
public
static void main(String argv[]) {
JFrame frm = new
JFrame();
JComboBox box = new
JComboBox();
box.setEditable( true
);
frm.getContentPane().setLayout( new
BoxLayout(
frm.getContentPane(), BoxLayout.Y_AXIS )
);
frm.getContentPane().add( box
);
box.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.exit( 0
);
}
}
);
frm.getContentPane().add( new JCheckBox( "Click" )
);
frm.pack();
frm.setVisible( true
);
}
}