FileDocCategorySizeDatePackage
TogglePanel.javaAPI DocExample996Fri Dec 07 10:11:02 GMT 2001None

TogglePanel

public class TogglePanel extends JPanel

Fields Summary
private JTextField
log
Constructors Summary
public TogglePanel(JTextField tf)

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