SWING - Check Boxes

java.lang.Object
extended byjava.awt.Component
extended byjava.awt.Container
extended byjavax.swing.JComponent
extended byjavax.swing.AbstractButton
extended byjavax.swing.JToggleButton
extended byjavax.swing.JCheckBox

Constructor Summary
JCheckBox()
Creates an initially unselected check box button with no text, no icon.
JCheckBox(Action a)
Creates a check box where properties are taken from the Action supplied.
JCheckBox(Icon icon)
Creates an initially unselected check box with an icon.
JCheckBox(Icon icon, boolean selected)
Creates a check box with an icon and specifies whether or not it is initially selected.
JCheckBox(String text)
Creates an initially unselected check box with text.
JCheckBox(String text, boolean selected)
Creates a check box with text and specifies whether or not it is initially selected.
JCheckBox(String text, Icon icon)
Creates an initially unselected check box with the specified text and icon.
JCheckBox(String text, Icon icon, boolean selected)
Creates a check box with text and icon, and specifies whether or not it is initially selected.

Method Summary
protected void configurePropertiesFromAction(Action a)
Factory method which sets the ActionEvent source's properties according to values from the Action instance.
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance.
AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JCheckBox.
String getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.
boolean isBorderPaintedFlat()
Gets the value of the borderPaintedFlat property.
protected String paramString()
Returns a string representation of this JCheckBox.
void setBorderPaintedFlat(boolean b)
Sets the borderPaintedFlat property, which gives a hint to the look and feel as to the appearance of the check box border.
void updateUI()
Resets the UI property to a value from the current look and feel.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class checkbox extends JApplet implements ItemListener{
JTextField text;
JCheckBox checkbox1, checkbox2, checkbox3, checkbox4;

public void init() {

Container frame1=getContentPane();
frame1.setLayout(new FlowLayout());


checkbox1=new JCheckBox("Check Box1");
checkbox2=new JCheckBox("Check Box2");
checkbox3=new JCheckBox("Check Boz3");
checkbox4=new JCheckBox("Check Box4");
text=new JTextField(20);

checkbox1.addItemListener(this);
checkbox2.addItemListener(this);
checkbox3.addItemListener(this);
checkbox4.addItemListener(this);

frame1.add(checkbox1);
frame1.add(checkbox2);
frame1.add(checkbox3);
frame1.add(checkbox4);

frame1.add(text);
}

public void itemStateChanged(ItemEvent e){
if(e.getItemSelectable()==checkbox1){
text.setText("Hello from Swing");
}else if(e.getItemSelectable()==checkbox2){
text.setText("Hello from Swing");
}else if(e.getItemSelectable()==checkbox3){
text.setText("Hello from Swing");
}else if(e.getItemSelectable()==checkbox4){
text.setText("Hello from Swing");
}


}
}