this.log=tf;
// Toggle button
JToggleButton tog = new JToggleButton("Toggle");
// listener for all 3 varieties
ItemListener listener = new ItemListener(){
public void itemStateChanged(ItemEvent e)
{
AbstractButton src = (AbstractButton)(e.getSource());
log.setText("Toggle: " + src.getText());
}
};
tog.addItemListener(listener);
add(tog);
// checkbox
JCheckBox cbox = new JCheckBox("CheckBox");
cbox.addItemListener(listener);
add(cbox);
// radio button boxes
ButtonGroup btngroup = new ButtonGroup();
for (int i=1;i<4;i++)
{
JRadioButton radio = new JRadioButton("Radio " + i);
btngroup.add(radio);
radio.addItemListener(listener);
add(radio);
}