public class CheckBox extends ButtonBase
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.setIndeterminate(false);
MnemonicParsing is enabled by default for CheckBox.
Type | Property and Description |
---|---|
BooleanProperty |
allowIndeterminate
Determines whether the user toggling the CheckBox should cycle through
all three states: checked, unchecked, and
undefined.
|
BooleanProperty |
indeterminate
Determines whether the CheckBox is in the indeterminate state.
|
BooleanProperty |
selected
Indicates whether this CheckBox is checked.
|
armedProperty, onActionProperty
alignmentProperty, contentDisplayProperty, ellipsisStringProperty, fontProperty, graphicProperty, graphicTextGapProperty, labelPaddingProperty, lineSpacingProperty, mnemonicParsingProperty, textAlignmentProperty, textFillProperty, textOverrunProperty, textProperty, underlineProperty, wrapTextProperty
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipProperty
Modifier and Type | Field and Description |
---|---|
private BooleanProperty |
allowIndeterminate
Determines whether the user toggling the CheckBox should cycle through
all three states: checked, unchecked, and
undefined.
|
private static java.lang.String |
DEFAULT_STYLE_CLASS
*
Stylesheet Handling *
*
|
private BooleanProperty |
indeterminate
Determines whether the CheckBox is in the indeterminate state.
|
private static PseudoClass |
PSEUDO_CLASS_DETERMINATE |
private static PseudoClass |
PSEUDO_CLASS_INDETERMINATE |
private static PseudoClass |
PSEUDO_CLASS_SELECTED |
private BooleanProperty |
selected
Indicates whether this CheckBox is checked.
|
Constructor and Description |
---|
CheckBox()
Creates a check box with an empty string for its label.
|
CheckBox(java.lang.String text)
Creates a check box with the specified text as its label.
|
Modifier and Type | Method and Description |
---|---|
BooleanProperty |
allowIndeterminateProperty()
Determines whether the user toggling the CheckBox should cycle through
all three states: checked, unchecked, and
undefined.
|
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
void |
fire()
Toggles the state of the
CheckBox . |
BooleanProperty |
indeterminateProperty()
Determines whether the CheckBox is in the indeterminate state.
|
private void |
initialize() |
boolean |
isAllowIndeterminate()
Gets the value of the property allowIndeterminate.
|
boolean |
isIndeterminate()
Gets the value of the property indeterminate.
|
boolean |
isSelected()
Gets the value of the property selected.
|
java.lang.Object |
queryAccessibleAttribute(AccessibleAttribute attribute,
java.lang.Object... parameters) |
BooleanProperty |
selectedProperty()
Indicates whether this CheckBox is checked.
|
void |
setAllowIndeterminate(boolean value)
Sets the value of the property allowIndeterminate.
|
void |
setIndeterminate(boolean value)
Sets the value of the property indeterminate.
|
void |
setSelected(boolean value)
Sets the value of the property selected.
|
arm, armedProperty, disarm, executeAccessibleAction, getOnAction, isArmed, onActionProperty, setOnAction
alignmentProperty, contentDisplayProperty, ellipsisStringProperty, fontProperty, getAlignment, getClassCssMetaData, getContentBias, getContentDisplay, getControlCssMetaData, getEllipsisString, getFont, getGraphic, getGraphicTextGap, getInitialAlignment, getLabelPadding, getLineSpacing, getText, getTextAlignment, getTextFill, getTextOverrun, graphicProperty, graphicTextGapProperty, isMnemonicParsing, isUnderline, isWrapText, labelPaddingProperty, lineSpacingProperty, mnemonicParsingProperty, setAlignment, setContentDisplay, setEllipsisString, setFont, setGraphic, setGraphicTextGap, setLineSpacing, setMnemonicParsing, setText, setTextAlignment, setTextFill, setTextOverrun, setUnderline, setWrapText, textAlignmentProperty, textFillProperty, textOverrunProperty, textProperty, toString, underlineProperty, wrapTextProperty
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, getBaselineOffset, getContextMenu, getControlChildren, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, loadSkinClass, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
public final BooleanProperty indeterminateProperty
isIndeterminate()
,
setIndeterminate(boolean)
public final BooleanProperty selectedProperty
isSelected()
,
setSelected(boolean)
public final BooleanProperty allowIndeterminateProperty
true
then all three states will be
cycled through; if false
then only checked and
unchecked will be cycled.private BooleanProperty indeterminate
private BooleanProperty selected
private BooleanProperty allowIndeterminate
true
then all three states will be
cycled through; if false
then only checked and
unchecked will be cycled.private static final java.lang.String DEFAULT_STYLE_CLASS
private static final PseudoClass PSEUDO_CLASS_DETERMINATE
private static final PseudoClass PSEUDO_CLASS_INDETERMINATE
private static final PseudoClass PSEUDO_CLASS_SELECTED
public CheckBox()
public CheckBox(java.lang.String text)
text
- A text string for its label.private void initialize()
public final void setIndeterminate(boolean value)
public final boolean isIndeterminate()
public final BooleanProperty indeterminateProperty()
isIndeterminate()
,
setIndeterminate(boolean)
public final void setSelected(boolean value)
public final boolean isSelected()
public final BooleanProperty selectedProperty()
isSelected()
,
setSelected(boolean)
public final void setAllowIndeterminate(boolean value)
public final boolean isAllowIndeterminate()
public final BooleanProperty allowIndeterminateProperty()
true
then all three states will be
cycled through; if false
then only checked and
unchecked will be cycled.public void fire()
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.fire
in class ButtonBase
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.createDefaultSkin
in class Control
public java.lang.Object queryAccessibleAttribute(AccessibleAttribute attribute, java.lang.Object... parameters)
queryAccessibleAttribute
in class Control