public class Checkbox extends Component implements ItemSelectable, Accessible, Serializable
| Modifier and Type | Class and Description |
|---|---|
protected class |
Checkbox.AccessibleAWTCheckbox
This class provides accessibility support for the
checkbox.
|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategyBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
Checkbox()
Initializes a new instance of
Checkbox with no label,
an initial state of off, and that is not part of any checkbox group. |
Checkbox(String label)
Initializes a new instance of
Checkbox with the specified
label, an initial state of off, and that is not part of any checkbox
group. |
Checkbox(String label,
boolean state)
Initializes a new instance of
Checkbox with the specified
label and initial state, and that is not part of any checkbox
group. |
Checkbox(String label,
boolean state,
CheckboxGroup group)
Initializes a new instance of
Checkbox with the specified
label, initial state, and checkbox group. |
Checkbox(String label,
CheckboxGroup group,
boolean state)
Initializes a new instance of
Checkbox with the specified
label, initial state, and checkbox group. |
| Modifier and Type | Method and Description |
|---|---|
void |
addItemListener(ItemListener listener)
Adds a new listeners to the list of registered listeners for this object.
|
void |
addNotify()
Creates this object's native peer.
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this
Checkbox. |
CheckboxGroup |
getCheckboxGroup()
Returns the checkbox group this object is a member of, if any.
|
ItemListener[] |
getItemListeners() |
String |
getLabel()
Returns the label for this checkbox.
|
Object[] |
getSelectedObjects()
Returns an array of length one containing the checkbox label if this
checkbox is selected.
|
boolean |
getState()
Returns the state of this checkbox.
|
protected String |
paramString()
Returns a debugging string for this object.
|
protected void |
processEvent(AWTEvent event)
Processes this event by calling
processItemEvent() if it
is any instance of ItemEvent. |
protected void |
processItemEvent(ItemEvent event)
Processes this event by dispatching it to any registered listeners.
|
void |
removeItemListener(ItemListener listener)
Removes a listener from the list of registered listeners for this object.
|
void |
setCheckboxGroup(CheckboxGroup group)
Sets this object's checkbox group to the specified group.
|
void |
setLabel(String label)
Sets the label for this checkbox to the specified value.
|
void |
setState(boolean state)
Sets the state of this checkbox to the specified value.
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validatepublic Checkbox()
Checkbox with no label,
an initial state of off, and that is not part of any checkbox group.public Checkbox(String label)
Checkbox with the specified
label, an initial state of off, and that is not part of any checkbox
group.label - The label for this checkbox.public Checkbox(String label, boolean state)
Checkbox with the specified
label and initial state, and that is not part of any checkbox
group.label - The label for this checkbox.state - The initial state of the checkbox, true for
on, false for off.public Checkbox(String label, CheckboxGroup group, boolean state)
Checkbox with the specified
label, initial state, and checkbox group.label - The label for this checkbox.group - The checkbox group for this box, or null
if there is no checkbox group.state - The initial state of the checkbox, true for
on, false for off.public Checkbox(String label, boolean state, CheckboxGroup group)
Checkbox with the specified
label, initial state, and checkbox group.label - The label for this checkbox.state - The initial state of the checkbox, true for
on, false for off.group - The checkbox group for this box, or null
if there is no checkbox group.public String getLabel()
public void setLabel(String label)
label - The new checkbox label.public boolean getState()
true for
on and false for off.public void setState(boolean state)
state - The new state of the checkbox, which will be true
for on or false for off.public Object[] getSelectedObjects()
null is returned.getSelectedObjects in interface ItemSelectablepublic CheckboxGroup getCheckboxGroup()
null if it is
not a member of any group.public void setCheckboxGroup(CheckboxGroup group)
group - The new checkbox group, or null to make this
object part of no checkbox group.public void addNotify()
addNotify in class ComponentComponent.isDisplayable(),
Component.removeNotify()public ItemListener[] getItemListeners()
public void addItemListener(ItemListener listener)
addItemListener in interface ItemSelectablelistener - The new listener to add.public void removeItemListener(ItemListener listener)
removeItemListener in interface ItemSelectablelistener - The listener to remove.protected void processEvent(AWTEvent event)
processItemEvent() if it
is any instance of ItemEvent. Otherwise it is passed to
the superclass for processing.processEvent in class Componentevent - The event to process.Component.processComponentEvent(ComponentEvent),
Component.processFocusEvent(FocusEvent),
Component.processKeyEvent(KeyEvent),
Component.processMouseEvent(MouseEvent),
Component.processMouseMotionEvent(MouseEvent),
Component.processInputMethodEvent(InputMethodEvent),
Component.processHierarchyEvent(HierarchyEvent),
Component.processMouseWheelEvent(MouseWheelEvent)protected void processItemEvent(ItemEvent event)
event - The ItemEvent to process.protected String paramString()
paramString in class Componentpublic AccessibleContext getAccessibleContext()
Checkbox.
The context is created, if necessary.getAccessibleContext in interface AccessiblegetAccessibleContext in class Component