Applying Check Boxes

A check box is a control that is used to-turn an option on or off. It consists of a small box that can either contain a check mark or not. There is a label associated with each check box that describes what option the box represents -,You change the state of a check box, by clicking on it. Check boxes can be used individually or as part of a group. Check boxes are objects of the Check box class. Check box supports these constructors:

Checkbox( )
Checkbox(String str) .
Checkbox(String str, boolean on)
Checkboxtstring-str, boolean on, CheckboxGroup cbGroup)
Checkbox(String str, CheckboxGroup cbGrollp, boolean on)

The first form creates a check box whose label is initially blank. The state of the  chec kbox is unchecked. The second form creates a check box whose label is specified by sir  The state of the check box is unchecked. The third form allows you to set the initial state of the check box. If 0" is true, the check box is initially  hecked; otherwise, it is cleared. The fourth and fifth forms create a check box whose label is specified by and whose group is specified by  If this check box is not part of a group, then must be null. (Check box groups are described in the next section.) The value of on determines the initial state of the check box. To retrieve the current state of a check box,  To set its state, call  You can obtain the current label associated with a check box by calling To set the label, call  These methods arc as follows:

Handling Check Boxes

Each time a check box is selected or deselected, all item event is generated. This dissent to any listeners that previously registered an interest in receiving item event notifications (rom that component. Each listener implements the Item Listener interface. That interface ..

be selected at anyone time. T~ create a set of mutually exclusive check boxes, you must first define the group to which  will belong and then specify that group .when you· .construct the check boxes. Check box groups are objects p£ type Check box Croup Only  the default constructor is defined; which creates an empty group  You can determine which check box in a group is currently selected by calling  You can set a: check box by calling  These methods are as follows:

Choice Control

The Choke class is used to create a pop-up list of items from which the user may
choose. Thus, a Choice control is a form of menu. When Inactive. a Choice component takes up only enough space to show the currently selected item. When the user clicks ' on it, the whole list of choices pops up, and a new selection can be made. Each item in the list is a string that appears as a left-justified label in the order it is added to the Choice object. Choice only defines the default constructor, which creates an empty list. To add a selection to the list, call add Item() or addl They have these general forms:

Handling Choice Lists

Each time a choice is selected, an item event is generated. This is sent to any listeners that previously registered an interest in receiving item event notifications from that component. Each listener implements the Item  interface, That interface defines , the item State Changed method. An Item Event object is supplied as the argument to this method.

Share This