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:
- makeGroup takes an array of labels and
an array of values and creates a group
of radio buttons with associated values for each button.
- makeCollection takes the same parameters
and produces an array of individual check boxes
Behavior
- When the checkbox is pressed, it will be displayed in its next state.
- If the checkbox is pressed and the mouse is dragged outside the button,
the checkbox will be displayed in its previous state, ie the activation
is temporarily cancelled until the mouse is dragged within the checkbox.
- If the mouse button is pressed and then released within the checkbox,
the checkbox is cycled to its next state, and an event is generated.
- If the space key is hit, the checkbox will cycle to its next
state. This is equivalent to clicking it.
Properties
Events
Class | Listener | Description |
JCItemEvent | addItemListener | Posted when the button's state changes |
-
ind_height
- Calculated indicator size.
-
ind_width
- Calculated indicator size.
-
ind_x
- Calculated indicator position.
-
ind_y
- Calculated indicator position.
-
INDETERMINATE
-
-
INDICATOR_CHECK
-
-
INDICATOR_CIRCLE
-
-
INDICATOR_CROSS
-
-
INDICATOR_DIAMOND
-
-
INDICATOR_FILL
-
-
INDICATOR_IMAGE
-
-
indicator_set
- Whether setIndicator() has been called.
-
INDICATOR_SIZE
- Default indicator size.
-
itemListeners
- List of JCItemEvent listeners
-
label_offset
- Separation between the indicator and the label.
-
OFF
-
-
ON
-
-
JCCheckbox()
- Creates an empty checkbox.
-
JCCheckbox(Object)
- Creates a checkbox with the specified label.
-
JCCheckbox(Object, Applet, String)
- Creates a checkbox which reads parameters from the applet's HTML file.
-
JCCheckbox(Object, int, JCCheckboxGroup)
- Creates a button with the specified label, set to the
specified state, and in the specified check box group.
-
JCCheckbox(Object, JCCheckboxGroup, int)
- Creates a button as part of a CheckboxGroup.
-
addItemListener(JCItemListener)
- Adds the specified item listener to receive item events from this checkbox.
-
addNotify()
- Calculates indicator size.
-
armAction(Event)
- Temporarily changes the state.
-
clickAction(Event)
- Changes the button's state and posts an JCItemEvent.
-
drawHighlight(Graphics, boolean)
- Draws or clears the highlight rectangle (called by paint).
-
drawIndicator(Graphics)
- Draws the indicator.
-
getCheckboxGroup()
- Returns the checkbox group.
-
getIndicator()
- Gets the Indicator value.
-
getIndicatorImageList()
- Gets the IndicatorImageList value.
-
getIndicatorImageURLList()
- Gets the IndicatorImageList value.
-
getNumStates()
- Gets the NumStates value.
-
getParameters()
- Reads the parameter values from the HTML page using the component's applet.
-
getSelectColor()
- Gets the SelectColor value.
-
getSelectedIndexes()
- Returns an array (length 1) containing the selected index (0),
or null if the checkbox is not set.
-
getSelectedObjects()
- Returns the an array (length 1) containing the checkbox
label, or null if the checkbox is not set.
-
getState()
- Gets the current state.
-
getUnselectColor()
- Gets the UnselectColor value.
-
keyDown(Event, int)
- If key is space, calls armAction, clickAction
-
layout()
- Lays out the label's internal elements.
-
makeGroup(Object[], int[], boolean)
- This static function creates a group of buttons.
-
mouseDown(Event, int, int)
- Calls armAction if btn1 was pressed.
-
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.
-
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.
-
mouseUp(Event, int, int)
- If the cursor is within the button, calls clickAction
-
paintComponent(Graphics)
- Draws indicator and label
-
preferredHeight()
- Gets the subclass' preferred height (default: 100).
-
preferredWidth()
- Gets the subclass' preferred width (default: 100).
-
removeItemListener(JCItemListener)
- Removes the specified item listener so it no longer receives
item events from this checkbox.
-
setCheckboxGroup(JCCheckboxGroup)
- Sets this button to the specified group.
-
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
-
setIndicatorImageList(Image[])
- Sets a list of indicator images to be used if Indicator is INDICATOR_IMAGE.
-
setIndicatorImageURLList(URL[])
- Sets a list of indicator images to be used if Indicator is INDICATOR_IMAGE.
-
setIndicatorSize()
- Set the indicator size.
-
setNumStates(int)
- Sets the maximum number of states that can be set (default: 2).
-
setSelectColor(Color)
- The color of the indicator background when the button is set
(default: Color.white).
-
setState(int)
- Sets the button's state.
-
setState(int, boolean)
- Sets the button's state, optionally specifying that the button's
events are to be posted.
-
setUnselectColor(Color)
- The color of the indicator background when the button is not set
(default: Color.white).
INDICATOR_FILL
public static final int INDICATOR_FILL
INDICATOR_CHECK
public static final int INDICATOR_CHECK
INDICATOR_CIRCLE
public static final int INDICATOR_CIRCLE
INDICATOR_CROSS
public static final int INDICATOR_CROSS
INDICATOR_DIAMOND
public static final int INDICATOR_DIAMOND
INDICATOR_IMAGE
public static final int INDICATOR_IMAGE
OFF
public static final int OFF
ON
public static final int ON
INDETERMINATE
public static final int INDETERMINATE
label_offset
protected int label_offset
- Separation between the indicator and the label.
ind_height
protected int ind_height
- Calculated indicator size.
ind_width
protected int ind_width
- Calculated indicator size.
ind_x
protected int ind_x
- Calculated indicator position.
ind_y
protected int ind_y
- Calculated indicator position.
indicator_set
protected boolean indicator_set
- Whether setIndicator() has been called.
itemListeners
protected JCVector itemListeners
- List of JCItemEvent listeners
INDICATOR_SIZE
public static final int INDICATOR_SIZE
- Default indicator size.
JCCheckbox
public JCCheckbox()
- Creates an empty checkbox. No parameters are read from an HTML file.
JCCheckbox
public JCCheckbox(Object label)
- Creates a checkbox with the specified label.
No parameters are read from an HTML file.
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
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
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
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
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
getIndicator
public int getIndicator()
- Gets the Indicator value.
- See Also:
- setIndicator
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
getIndicatorImageList
public Image[] getIndicatorImageList()
- Gets the IndicatorImageList value.
- See Also:
- setIndicatorImageList
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
getIndicatorImageURLList
public URL[] getIndicatorImageURLList()
- Gets the IndicatorImageList value.
- See Also:
- setIndicatorImageList
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
getNumStates
public int getNumStates()
- Gets the NumStates value.
- See Also:
- setNumStates
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
getSelectColor
public Color getSelectColor()
- Gets the SelectColor value.
- See Also:
- setSelectColor
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
getUnselectColor
public Color getUnselectColor()
- Gets the UnselectColor value.
- See Also:
- setUnselectColor
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
getState
public int getState()
- Gets the current state.
- See Also:
- setState
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
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
getCheckboxGroup
public JCCheckboxGroup getCheckboxGroup()
- Returns the checkbox group.
- See Also:
- setCheckboxGroup
setCheckboxGroup
public void setCheckboxGroup(JCCheckboxGroup g)
- Sets this button to the specified group.
The previous group's current button is unset.
setIndicatorSize
protected void setIndicatorSize()
- Set the indicator size.
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
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
addNotify
public void addNotify()
- Calculates indicator size.
- Overrides:
- addNotify in class JCLabel
layout
public synchronized void layout()
- Lays out the label's internal elements.
- Overrides:
- layout in class JCLabel
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
paintComponent
protected void paintComponent(Graphics gc)
- Draws indicator and label
- Overrides:
- paintComponent in class JCLabel
drawIndicator
protected void drawIndicator(Graphics gc)
- Draws the indicator.
preferredWidth
protected int preferredWidth()
- Gets the subclass' preferred width (default: 100).
- Overrides:
- preferredWidth in class JCLabel
preferredHeight
protected int preferredHeight()
- Gets the subclass' preferred height (default: 100).
- Overrides:
- preferredHeight in class JCLabel
addItemListener
public void addItemListener(JCItemListener l)
- Adds the specified item listener to receive item events from this checkbox.
- See Also:
- JCItemEvent
removeItemListener
public void removeItemListener(JCItemListener l)
- Removes the specified item listener so it no longer receives
item events from this checkbox.
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
clickAction
public void clickAction(Event ev)
- Changes the button's state and posts an JCItemEvent.
- See Also:
- setState, addItemListener
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
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
mouseDown
public boolean mouseDown(Event ev,
int x,
int y)
- Calls armAction if btn1 was pressed.
- Overrides:
- mouseDown in class JCComponent
- See Also:
- armAction
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
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