An implementation of a check box -- an item that can be selected or
deselected, and which displays its state to the user.
By convention, any number of check boxes in a group can be selected.
See How to Use Buttonc, Check Boxes, and Radio Buttons
in The Java Tutorial
for examples and information on using check boxes.
For the keyboard keys used by this component in the standard Look and
Feel (L&F) renditions, see the
JCheckBox key assignments.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is appropriate
for short term storage or RMI between applications running the same
version of Swing. A future release of Swing will provide support for
long term persistence.
createActionPropertyChangeListener(Action a)
Factory method which creates the PropertyChangeListener
used to update the ActionEvent source as properties change on
its Action instance.
Creates an initially unselected check box with
the specified text and icon.
Parameters:
text - the text of the check box.
icon - the Icon image to display
JCheckBox
public JCheckBox(String text,
Icon icon,
boolean selected)
Creates a check box with text and icon,
and specifies whether or not it is initially selected.
Parameters:
text - the text of the check box.
icon - the Icon image to display
selected - a boolean value indicating the initial selection
state. If true the check box is selected
Method Detail
setBorderPaintedFlat
public void setBorderPaintedFlat(boolean b)
Sets whether the border should be painted flat. This is usually
set to true when a JCheckBox instance is used as a renderer in a
component such as a JTable or JTree.
protected void configurePropertiesFromAction(Action a)
Factory method which sets the ActionEvent source's properties
according to values from the Action instance. The properties
which are set may differ for subclasses.
By default, the properties which get set are Text, Icon
Enabled, and ToolTipText.
Factory method which creates the PropertyChangeListener
used to update the ActionEvent source as properties change on
its Action instance. Subclasses may override this in order
to provide their own PropertyChangeListener if the set of
properties which should be kept up to date differs from the
default properties (Text, Icon, Enabled, ToolTipText).
Note that PropertyChangeListeners should avoid holding
strong references to the ActionEvent source, as this may hinder
garbage collection of the ActionEvent source and all components
in its containment hierarchy.
Returns a string representation of this JCheckBox. This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null.
specific new aspects of the JFC components.
Gets the AccessibleContext associated with this JCheckBox.
For JCheckBoxes, the AccessibleContext takes the form of an
AccessibleJCheckBox.
A new AccessibleJCheckBox instance is created if necessary.
Submit a bug or feature For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, California, 94303, U.S.A. All Rights Reserved.