APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.control

public Class CheckBox

extends ButtonBase
Class Inheritance
Imports
javafx.beans.property.BooleanProperty, .BooleanPropertyBase, .SimpleBooleanProperty, javafx.event.ActionEvent, javafx.geometry.Pos, javafx.css.PseudoClass, javafx.scene.AccessibleAttribute, .AccessibleRole, javafx.scene.control.skin.CheckBoxSkin

A tri-state selection Control typically skinned as a box with a checkmark or tick mark when checked. A CheckBox control can be in one of three states: If a CheckBox is checked, then it is also by definition defined. When checked the CheckBox is typically rendered with a "check" or "tick" mark. A CheckBox is in this state if selected is true and indeterminate is false.

A CheckBox is unchecked if selected is false and indeterminate is false.

A CheckBox is undefined if indeterminate is true, regardless of the state of selected. A typical rendering would be with a minus or dash, to indicate an undefined or indeterminate state of the CheckBox. This is convenient for constructing tri-state checkbox based trees, for example, where undefined check boxes typically mean "inherit settings from the parent".

The allowIndeterminate variable, if true, allows the user to cycle through the undefined state. If false, the CheckBox is not in the indeterminate state, and the user is allowed to change only the checked state.

Example:

 CheckBox cb = new CheckBox("a checkbox");
cb.setSelected(true);
Image of the CheckBox control

MnemonicParsing is enabled by default for CheckBox.

Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private BooleanProperty
allowIndeterminate

Determines whether the user toggling the CheckBox should cycle through all three states: checked, unchecked, and undefined.

private static final String
private BooleanProperty
indeterminate

Determines whether the CheckBox is in the indeterminate state.

private static final PseudoClass
private static final PseudoClass
private static final PseudoClass
private BooleanProperty
selected

Indicates whether this CheckBox is checked.

Constructor Summary

AccessConstructor and Description
public
CheckBox()

Creates a check box with an empty string for its label.

public
CheckBox(String
A text string for its label.
text
)

Creates a check box with the specified text as its label.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public void
fire()

Implements abstract javafx.scene.control.ButtonBase.fire.

Toggles the state of the CheckBox.

public final BooleanProperty
private void
public final boolean
public final boolean
public final boolean
public Object
queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

public final BooleanProperty
public final void
setAllowIndeterminate(boolean value)

public final void
setIndeterminate(boolean value)

public final void
setSelected(boolean value)

Inherited from javafx.scene.control.ButtonBase:
armarmedPropertydisarmexecuteAccessibleActiongetOnActionisArmedonActionPropertysetOnAction

Field Detail

allowIndeterminateback to summary
private BooleanProperty allowIndeterminate

Determines whether the user toggling the CheckBox should cycle through all three states: checked, unchecked, and undefined. If true then all three states will be cycled through; if false then only checked and unchecked will be cycled.

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS
indeterminateback to summary
private BooleanProperty indeterminate

Determines whether the CheckBox is in the indeterminate state.

PSEUDO_CLASS_DETERMINATEback to summary
private static final PseudoClass PSEUDO_CLASS_DETERMINATE
PSEUDO_CLASS_INDETERMINATEback to summary
private static final PseudoClass PSEUDO_CLASS_INDETERMINATE
PSEUDO_CLASS_SELECTEDback to summary
private static final PseudoClass PSEUDO_CLASS_SELECTED
selectedback to summary
private BooleanProperty selected

Indicates whether this CheckBox is checked.

Constructor Detail

CheckBoxback to summary
public CheckBox()

Creates a check box with an empty string for its label.

CheckBoxback to summary
public CheckBox(String text)

Creates a check box with the specified text as its label.

Parameters
text:String

A text string for its label.

Method Detail

allowIndeterminatePropertyback to summary
public final BooleanProperty allowIndeterminateProperty()
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
fireback to summary
public void fire()

Implements abstract javafx.scene.control.ButtonBase.fire.

Toggles the state of the CheckBox. If allowIndeterminate is true, then each invocation of this function will advance the CheckBox through the states checked, unchecked, and undefined. If allowIndeterminate is false, then the CheckBox will only cycle through the checked and unchecked states, and forcing indeterminate to equal to false.

Annotations
@Override
indeterminatePropertyback to summary
public final BooleanProperty indeterminateProperty()
initializeback to summary
private void initialize()
isAllowIndeterminateback to summary
public final boolean isAllowIndeterminate()
isIndeterminateback to summary
public final boolean isIndeterminate()
isSelectedback to summary
public final boolean isSelected()
queryAccessibleAttributeback to summary
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

Doc from javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

This method is commonly overridden by subclasses to implement attributes that are required for a specific role.
If a particular attribute is not handled, the superclass implementation must be called.

Annotations
@Override
selectedPropertyback to summary
public final BooleanProperty selectedProperty()
setAllowIndeterminateback to summary
public final void setAllowIndeterminate(boolean value)
setIndeterminateback to summary
public final void setIndeterminate(boolean value)
setSelectedback to summary
public final void setSelected(boolean value)