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 ); } } |