All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.bwt.JCCheckbox

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----jclass.bwt.JCComponent
                           |
                           +----jclass.bwt.JCLabel
                                   |
                                   +----jclass.bwt.JCCheckbox

public class JCCheckbox
extends JCLabel
implements JCItemSelectable
A component that is used for representing 2 or more states. It consists of an indicator and a label. It contains two functions for building groups of checkboxes:

Behavior

Properties

Name Method
Background setBackground
DoubleBuffer setDoubleBuffer
Font setFont
Foreground setForeground
HighlightColor setHighlightColor
HighlightThickness setHighlightThickness
Indicator setIndicator
IndicatorImageList setIndicatorImageList
Insets setInsets
Label setLabel
NumStates setNumStates
PreferredSize setPreferredSize
SelectColor setSelectColor
ShadowThickness setShadowThickness
State setState
Traversable setTraversable
UnselectColor setUnselectColor
UserData setUserData

Events

Class Listener Description
JCItemEvent addItemListener Posted when the button's state changes


Variable Index

 o ind_height
Calculated indicator size.
 o ind_width
Calculated indicator size.
 o ind_x
Calculated indicator position.
 o ind_y
Calculated indicator position.
 o INDETERMINATE
 o INDICATOR_CHECK
 o INDICATOR_CIRCLE
 o INDICATOR_CROSS
 o INDICATOR_DIAMOND
 o INDICATOR_FILL
 o INDICATOR_IMAGE
 o indicator_set
Whether setIndicator() has been called.
 o INDICATOR_SIZE
Default indicator size.
 o itemListeners
List of JCItemEvent listeners
 o label_offset
Separation between the indicator and the label.
 o OFF
 o ON

Constructor Index

 o JCCheckbox()
Creates an empty checkbox.
 o JCCheckbox(Object)
Creates a checkbox with the specified label.
 o JCCheckbox(Object, Applet, String)
Creates a checkbox which reads parameters from the applet's HTML file.
 o JCCheckbox(Object, int, JCCheckboxGroup)
Creates a button with the specified label, set to the specified state, and in the specified check box group.
 o JCCheckbox(Object, JCCheckboxGroup, int)
Creates a button as part of a CheckboxGroup.

Method Index

 o addItemListener(JCItemListener)
Adds the specified item listener to receive item events from this checkbox.
 o addNotify()
Calculates indicator size.
 o armAction(Event)
Temporarily changes the state.
 o clickAction(Event)
Changes the button's state and posts an JCItemEvent.
 o drawHighlight(Graphics, boolean)
Draws or clears the highlight rectangle (called by paint).
 o drawIndicator(Graphics)
Draws the indicator.
 o getCheckboxGroup()
Returns the checkbox group.
 o getIndicator()
Gets the Indicator value.
 o getIndicatorImageList()
Gets the IndicatorImageList value.
 o getIndicatorImageURLList()
Gets the IndicatorImageList value.
 o getNumStates()
Gets the NumStates value.
 o getParameters()
Reads the parameter values from the HTML page using the component's applet.
 o getSelectColor()
Gets the SelectColor value.
 o getSelectedIndexes()
Returns an array (length 1) containing the selected index (0), or null if the checkbox is not set.
 o getSelectedObjects()
Returns the an array (length 1) containing the checkbox label, or null if the checkbox is not set.
 o getState()
Gets the current state.
 o getUnselectColor()
Gets the UnselectColor value.
 o keyDown(Event, int)
If key is space, calls armAction, clickAction
 o layout()
Lays out the label's internal elements.
 o makeGroup(Object[], int[], boolean)
This static function creates a group of buttons.
 o mouseDown(Event, int, int)
Calls armAction if btn1 was pressed.
 o mouseEnter(Event, int, int)
If the mouse was pressed and is moved inside the button, the state is reset to its original value and the indicator is redrawn.
 o mouseExit(Event, int, int)
If the mouse was pressed and is moved outside the button, the state is reset to its original value and the indicator is redrawn.
 o mouseUp(Event, int, int)
If the cursor is within the button, calls clickAction
 o paintComponent(Graphics)
Draws indicator and label
 o preferredHeight()
Gets the subclass' preferred height (default: 100).
 o preferredWidth()
Gets the subclass' preferred width (default: 100).
 o removeItemListener(JCItemListener)
Removes the specified item listener so it no longer receives item events from this checkbox.
 o setCheckboxGroup(JCCheckboxGroup)
Sets this button to the specified group.
 o setIndicator(int)
Sets the indicator style:
INDICATOR_FILL     Indicator is drawn, and its shadows are switched
INDICATOR_CHECK    Checkmark 
INDICATOR_CIRCLE   Circle 
INDICATOR_CROSS    X (default)
INDICATOR_DIAMOND  Diamond
INDICATOR_IMAGE    Image specified by ImageList

HTML param name/value: "Indicator"/enum

 o setIndicatorImageList(Image[])
Sets a list of indicator images to be used if Indicator is INDICATOR_IMAGE.
 o setIndicatorImageURLList(URL[])
Sets a list of indicator images to be used if Indicator is INDICATOR_IMAGE.
 o setIndicatorSize()
Set the indicator size.
 o setNumStates(int)
Sets the maximum number of states that can be set (default: 2).
 o setSelectColor(Color)
The color of the indicator background when the button is set (default: Color.white).
 o setState(int)
Sets the button's state.
 o setState(int, boolean)
Sets the button's state, optionally specifying that the button's events are to be posted.
 o setUnselectColor(Color)
The color of the indicator background when the button is not set (default: Color.white).

Variables

 o INDICATOR_FILL
 public static final int INDICATOR_FILL
 o INDICATOR_CHECK
 public static final int INDICATOR_CHECK
 o INDICATOR_CIRCLE
 public static final int INDICATOR_CIRCLE
 o INDICATOR_CROSS
 public static final int INDICATOR_CROSS
 o INDICATOR_DIAMOND
 public static final int INDICATOR_DIAMOND
 o INDICATOR_IMAGE
 public static final int INDICATOR_IMAGE
 o OFF
 public static final int OFF
 o ON
 public static final int ON
 o INDETERMINATE
 public static final int INDETERMINATE
 o label_offset
 protected int label_offset
Separation between the indicator and the label.

 o ind_height
 protected int ind_height
Calculated indicator size.

 o ind_width
 protected int ind_width
Calculated indicator size.

 o ind_x
 protected int ind_x
Calculated indicator position.

 o ind_y
 protected int ind_y
Calculated indicator position.

 o indicator_set
 protected boolean indicator_set
Whether setIndicator() has been called.

 o itemListeners
 protected JCVector itemListeners
List of JCItemEvent listeners

 o INDICATOR_SIZE
 public static final int INDICATOR_SIZE
Default indicator size.

Constructors

 o JCCheckbox
 public JCCheckbox()
Creates an empty checkbox. No parameters are read from an HTML file.

 o JCCheckbox
 public JCCheckbox(Object label)
Creates a checkbox with the specified label. No parameters are read from an HTML file.

 o JCCheckbox
 public JCCheckbox(Object label,
                   Applet applet,
                   String name)
Creates a checkbox which reads parameters from the applet's HTML file.

Parameters:
applet - the applet whose PARAM tags are to be read
name - if this is not null, only parameters preceded by this name are read
See Also:
getParameter
 o JCCheckbox
 public JCCheckbox(Object label,
                   JCCheckboxGroup group,
                   int value)
Creates a button as part of a CheckboxGroup.

Parameters:
label - the checkbox's label
group - the "owner" of the box. This can be null.
value - the userdata associated with the checkbox. This can be retrieved by calling getUserDataInt(). If the checkbox is currently selected, calling the group's getValue() method will return this value.
See Also:
getValue, getUserDataInt
 o JCCheckbox
 public JCCheckbox(Object label,
                   int state,
                   JCCheckboxGroup group)
Creates a button with the specified label, set to the specified state, and in the specified check box group.

Parameters:
label - the label on the Checkbox
state - is the initial state of this Checkbox
group - the CheckboxGroup this Checkbox is in
See Also:
setState

Methods

 o getParameters
 protected void getParameters()
Reads the parameter values from the HTML page using the component's applet. The values will override those previously set.

Overrides:
getParameters in class JCLabel
 o makeGroup
 public static JCCheckboxGroup makeGroup(Object labels[],
                                         int values[],
                                         boolean radio_behavior)
This static function creates a group of buttons.

Parameters:
labels - a list of labels for each checkbox
values - a list of values for each checkbox (may be null)
radio_behavior - if true, setting one checkbox will deselect any other
Returns:
a JCCheckboxGroup containing the check boxes
See Also:
setRadioBehavior
 o getIndicator
 public int getIndicator()
Gets the Indicator value.

See Also:
setIndicator
 o setIndicator
 public synchronized void setIndicator(int v)
Sets the indicator style:
INDICATOR_FILL     Indicator is drawn, and its shadows are switched
INDICATOR_CHECK    Checkmark 
INDICATOR_CIRCLE   Circle 
INDICATOR_CROSS    X (default)
INDICATOR_DIAMOND  Diamond
INDICATOR_IMAGE    Image specified by ImageList

HTML param name/value: "Indicator"/enum

Throws: IllegalArgumentException
If an invalid value is set
See Also:
setState, toEnum
 o getIndicatorImageList
 public Image[] getIndicatorImageList()
Gets the IndicatorImageList value.

See Also:
setIndicatorImageList
 o setIndicatorImageList
 public synchronized void setIndicatorImageList(Image v[])
Sets a list of indicator images to be used if Indicator is INDICATOR_IMAGE. If this property is not set, no indicator is displayed. The position of the image within the list is specified by the State value. HTML param name/value: "IndicatorImageList"/comma-separated list of images

See Also:
toImageList, setIndicator, setState
 o getIndicatorImageURLList
 public URL[] getIndicatorImageURLList()
Gets the IndicatorImageList value.

See Also:
setIndicatorImageList
 o setIndicatorImageURLList
 public synchronized void setIndicatorImageURLList(URL list[])
Sets a list of indicator images to be used if Indicator is INDICATOR_IMAGE. If this property is not set, no indicator is displayed. The position of the image within the list is specified by the State value. HTML param name/value: "IndicatorImageList"/comma-separated list of images

See Also:
toImageList, setIndicator, setState
 o getNumStates
 public int getNumStates()
Gets the NumStates value.

See Also:
setNumStates
 o setNumStates
 public synchronized void setNumStates(int v)
Sets the maximum number of states that can be set (default: 2). By default, the button can be set to OFF and ON.

HTML param name/value: "NumStates"/int

 o getSelectColor
 public Color getSelectColor()
Gets the SelectColor value.

See Also:
setSelectColor
 o setSelectColor
 public synchronized void setSelectColor(Color v)
The color of the indicator background when the button is set (default: Color.white). If set to null, the indicator will be filled with the current background color.

This value only applies to FILL and DIAMOND indicators. All other indicators are filled with a white background.

HTML param name/value: "SelectColor"/Color

See Also:
setIndicator, toColor
 o getUnselectColor
 public Color getUnselectColor()
Gets the UnselectColor value.

See Also:
setUnselectColor
 o setUnselectColor
 public synchronized void setUnselectColor(Color v)
The color of the indicator background when the button is not set (default: Color.white). If set to null, the indicator will be filled with the current background color.

This value only applies to FILL and DIAMOND indicators. All other indicators are filled with a white background.

HTML param name/value: "UnselectColor"/Color

See Also:
setIndicator, toColor
 o getState
 public int getState()
Gets the current state.

See Also:
setState
 o setState
 public synchronized void setState(int state)
Sets the button's state. For convenience, the following ints are provided: OFF (0), ON (1) and INDETERMINATE (2). The number of states is specified by NumStates. As the user clicks on the button, the value of State increments through the states, and then back to 0 (OFF). The button's clickAction() method is not called, and thus no events are posted.

HTML param name/value: "State"/int, "ON", or "OFF"

See Also:
setNumStates, getState, toInt
 o setState
 public synchronized void setState(int state,
                                   boolean notify)
Sets the button's state, optionally specifying that the button's events are to be posted.

Parameters:
notify - if true the button's clickAction() method is called
See Also:
clickAction
 o getCheckboxGroup
 public JCCheckboxGroup getCheckboxGroup()
Returns the checkbox group.

See Also:
setCheckboxGroup
 o setCheckboxGroup
 public void setCheckboxGroup(JCCheckboxGroup g)
Sets this button to the specified group. The previous group's current button is unset.

 o setIndicatorSize
 protected void setIndicatorSize()
Set the indicator size.

 o getSelectedIndexes
 public int[] getSelectedIndexes()
Returns an array (length 1) containing the selected index (0), or null if the checkbox is not set.

See Also:
JCItemSelectable
 o getSelectedObjects
 public Object[] getSelectedObjects()
Returns the an array (length 1) containing the checkbox label, or null if the checkbox is not set.

See Also:
JCItemSelectable
 o addNotify
 public void addNotify()
Calculates indicator size.

Overrides:
addNotify in class JCLabel
 o layout
 public synchronized void layout()
Lays out the label's internal elements.

Overrides:
layout in class JCLabel
 o drawHighlight
 protected void drawHighlight(Graphics gc,
                              boolean on)
Draws or clears the highlight rectangle (called by paint).

Parameters:
on - if true, draws the highlight rectangle and a dashed rectangle around the label; otherwise clears the rect
Overrides:
drawHighlight in class JCComponent
 o paintComponent
 protected void paintComponent(Graphics gc)
Draws indicator and label

Overrides:
paintComponent in class JCLabel
 o drawIndicator
 protected void drawIndicator(Graphics gc)
Draws the indicator.

 o preferredWidth
 protected int preferredWidth()
Gets the subclass' preferred width (default: 100).

Overrides:
preferredWidth in class JCLabel
 o preferredHeight
 protected int preferredHeight()
Gets the subclass' preferred height (default: 100).

Overrides:
preferredHeight in class JCLabel
 o addItemListener
 public void addItemListener(JCItemListener l)
Adds the specified item listener to receive item events from this checkbox.

See Also:
JCItemEvent
 o removeItemListener
 public void removeItemListener(JCItemListener l)
Removes the specified item listener so it no longer receives item events from this checkbox.

 o armAction
 public void armAction(Event ev)
Temporarily changes the state. The state is not set permanently until clickAction() is called, since the user may release the mouse button while the cursor is outside the checkbox.

See Also:
clickAction
 o clickAction
 public void clickAction(Event ev)
Changes the button's state and posts an JCItemEvent.

See Also:
setState, addItemListener
 o mouseExit
 public boolean mouseExit(Event ev,
                          int x,
                          int y)
If the mouse was pressed and is moved outside the button, the state is reset to its original value and the indicator is redrawn.

Overrides:
mouseExit in class Component
 o mouseEnter
 public boolean mouseEnter(Event ev,
                           int x,
                           int y)
If the mouse was pressed and is moved inside the button, the state is reset to its original value and the indicator is redrawn.

Overrides:
mouseEnter in class Component
 o mouseDown
 public boolean mouseDown(Event ev,
                          int x,
                          int y)
Calls armAction if btn1 was pressed.

Overrides:
mouseDown in class JCComponent
See Also:
armAction
 o mouseUp
 public boolean mouseUp(Event ev,
                        int x,
                        int y)
If the cursor is within the button, calls clickAction

Overrides:
mouseUp in class JCLabel
See Also:
clickAction
 o keyDown
 public boolean keyDown(Event ev,
                        int key)
If key is space, calls armAction, clickAction

Overrides:
keyDown in class Component
See Also:
armAction, clickAction

All Packages  Class Hierarchy  This Package  Previous  Next  Index