public class RadioButton extends ToggleButton
RadioButtons create a series of items where only one item can be
selected. RadioButtons are a specialized ToggleButton
.
When a RadioButton is pressed and released a javafx.event.ActionEvent
is sent. Your application can perform some action based
on this event by implementing an javafx.event.EventHandler
to
process the javafx.event.ActionEvent
.
Only one RadioButton can be selected when placed in a ToggleGroup
.
Clicking on a selected RadioButton will have no effect. A RadioButton that is not
in a ToggleGroup can be selected and unselected. By default a RadioButton is
not in a ToggleGroup. Calling ToggleGroup.getSelectedToggle()
will return you the RadioButton that has been selected.
ToggleGroup group = new ToggleGroup();
RadioButton button1 = new RadioButton("select first");
button1.setToggleGroup(group);
button1.setSelected(true);
RadioButton button2 = new RadioButton("select second");
button2.setToggleGroup(group);
selectedProperty, toggleGroupProperty
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 static java.lang.String |
DEFAULT_STYLE_CLASS
*
Stylesheet Handling *
*
|
Constructor and Description |
---|
RadioButton()
Creates a radio button with an empty string for its label.
|
RadioButton(java.lang.String text)
Creates a radio button with the specified text as its label.
|
Modifier and Type | Method and Description |
---|---|
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
void |
fire()
Toggles the state of the radio button if and only if the RadioButton
has not already selected or is not part of a
ToggleGroup . |
protected Pos |
getInitialAlignment()
Returns the initial alignment state of this control, for use
by the JavaFX CSS engine to correctly set its initial value.
|
private void |
initialize() |
java.lang.Object |
queryAccessibleAttribute(AccessibleAttribute attribute,
java.lang.Object... parameters) |
getToggleGroup, isSelected, selectedProperty, setSelected, setToggleGroup, toggleGroupProperty
arm, armedProperty, disarm, executeAccessibleAction, getOnAction, isArmed, onActionProperty, setOnAction
alignmentProperty, contentDisplayProperty, ellipsisStringProperty, fontProperty, getAlignment, getClassCssMetaData, getContentBias, getContentDisplay, getControlCssMetaData, getEllipsisString, getFont, getGraphic, getGraphicTextGap, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getProperties, getUserData, setUserData
private static final java.lang.String DEFAULT_STYLE_CLASS
public RadioButton()
public RadioButton(java.lang.String text)
text
- A text string for its label.private void initialize()
public void fire()
ToggleGroup
.fire
in class ToggleButton
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.createDefaultSkin
in class ToggleButton
protected Pos getInitialAlignment()
getInitialAlignment
in class ToggleButton
public java.lang.Object queryAccessibleAttribute(AccessibleAttribute attribute, java.lang.Object... parameters)
queryAccessibleAttribute
in class ToggleButton