java.awt

Class Checkbox

Implemented Interfaces:
Accessible, ImageObserver, ItemSelectable, MenuContainer, Serializable

public class Checkbox
extends Component
implements ItemSelectable, Accessible, Serializable

This class implements a component which has an on/off state. Two or more Checkboxes can be grouped by a CheckboxGroup.
See Also:
Serialized Form

Nested Class Summary

protected class
Checkbox.AccessibleAWTCheckbox
This class provides accessibility support for the checkbox.

Nested classes/interfaces inherited from class java.awt.Component

Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy

Field Summary

Fields inherited from class java.awt.Component

BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

Fields inherited from interface java.awt.image.ImageObserver

ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH

Constructor Summary

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.

Method Summary

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.

Methods inherited from class java.awt.Component

action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, 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, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, 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, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, 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, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Checkbox

public 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

public 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.
Parameters:
label - The label for this checkbox.

Checkbox

public 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.
Parameters:
label - The label for this checkbox.
state - The initial state of the checkbox, true for on, false for off.

Checkbox

public Checkbox(String label,
                boolean state,
                CheckboxGroup group)
Initializes a new instance of Checkbox with the specified label, initial state, and checkbox group.
Parameters:
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.

Checkbox

public Checkbox(String label,
                CheckboxGroup group,
                boolean state)
Initializes a new instance of Checkbox with the specified label, initial state, and checkbox group.
Parameters:
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.

Method Details

addItemListener

public void addItemListener(ItemListener listener)
Adds a new listeners to the list of registered listeners for this object.
Specified by:
addItemListener in interface ItemSelectable
Parameters:
listener - The new listener to add.

addNotify

public void addNotify()
Creates this object's native peer.
Overrides:
addNotify in interface Component

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Checkbox. The context is created, if necessary.
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in interface Component
Returns:
the associated context

getCheckboxGroup

public CheckboxGroup getCheckboxGroup()
Returns the checkbox group this object is a member of, if any.
Returns:
This object's checkbox group, of null if it is not a member of any group.

getItemListeners

public ItemListener[] getItemListeners()

getLabel

public String getLabel()
Returns the label for this checkbox.
Returns:
The label for this checkbox.

getSelectedObjects

public Object[] getSelectedObjects()
Returns an array of length one containing the checkbox label if this checkbox is selected. Otherwise null is returned.
Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
The selection state of this checkbox.

getState

public boolean getState()
Returns the state of this checkbox.
Returns:
The state of this checkbox, which will be true for on and false for off.

paramString

protected String paramString()
Returns a debugging string for this object.
Overrides:
paramString in interface Component

processEvent

protected void processEvent(AWTEvent event)
Processes this event by calling processItemEvent() if it is any instance of ItemEvent. Otherwise it is passed to the superclass for processing.
Overrides:
processEvent in interface Component
Parameters:
event - The event to process.

processItemEvent

protected void processItemEvent(ItemEvent event)
Processes this event by dispatching it to any registered listeners.
Parameters:
event - The ItemEvent to process.

removeItemListener

public void removeItemListener(ItemListener listener)
Removes a listener from the list of registered listeners for this object.
Specified by:
removeItemListener in interface ItemSelectable
Parameters:
listener - The listener to remove.

setCheckboxGroup

public void setCheckboxGroup(CheckboxGroup group)
Sets this object's checkbox group to the specified group.
Parameters:
group - The new checkbox group, or null to make this object part of no checkbox group.

setLabel

public void setLabel(String label)
Sets the label for this checkbox to the specified value.
Parameters:
label - The new checkbox label.

setState

public void setState(boolean state)
Sets the state of this checkbox to the specified value.
Parameters:
state - The new state of the checkbox, which will be true for on or false for off.

Checkbox.java -- An AWT checkbox widget Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.