Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information

Java Cup Logo

JDC Home Page


Top
Back
Next
Online Training
shadowSearchFAQFeedback

Checkbox

A Checkbox is a label with a small pushbutton. The state of a Checkbox is either true (button pushed in) or false (button out); the default initial state is false. Clicking on a Checkbox toggles the state.



Corresponding source code:

import java.applet.*;
import java.awt.*;
public class CheckboxWidget extends Applet {
    public void init()
    {
        Checkbox m = new Checkbox("Allow Mixed Case");
        add(m);
    }
}

Method:

  • public Checkbox(String label)
    Creates a Checkbox with the specified label.
  • public Checkbox(String label, CheckboxGroup g, boolean state)
    Constructor used when the Checkbox is a member of a CheckboxGroup.
  • public boolean getState()
    Is the Checkbox on or off?
  • public void setState(boolean state)
    Sets Checkbox to on or off.

Related exercises: