<<< The JCheckBox Class | Index | How to repaint the window >>> |
checkBox = new JCheckBox( "check label", false );
checkBox.addItemListener(
// using anonymous class without a name
new java.awt.event.ItemListener()
{
// method executes when status of the check box changes:
public void itemStateChanged( java.awt.event.ItemEvent evt ) {
JCheckBox source = ( JCheckBox ) evt.getItemSelectable();
if ( source == checkBox ) {
System.out.println( "box" + source.isSelected() );
}
}//itemStateChanged
}//anonymous class
);
frame.getContentPane().add(checkBox);
<<< The JCheckBox Class | Index | How to repaint the window >>> |