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

public Class RadioButton

extends ToggleButton
Class Inheritance
Imports
javafx.geometry.Pos, javafx.scene.control.skin.RadioButtonSkin, javafx.beans.value.WritableValue, javafx.css.StyleableProperty, javafx.scene.AccessibleAttribute, .AccessibleRole

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);
Image of the RadioButton control
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
public
RadioButton()

Creates a radio button with an empty string for its label.

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

Creates a radio button with the specified text as its label.

Method Summary

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

Overrides javafx.scene.control.ToggleButton.createDefaultSkin.

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

public void
fire()

Overrides javafx.scene.control.ToggleButton.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()

Overrides javafx.scene.control.ToggleButton.getInitialAlignment.

Returns the initial alignment state of this control, for use by the JavaFX CSS engine to correctly set its initial value.

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

Overrides javafx.scene.control.ToggleButton.queryAccessibleAttribute.

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

Inherited from javafx.scene.control.ToggleButton:
getToggleGroupisSelectedselectedPropertysetSelectedsetToggleGrouptoggleGroupProperty

Field Detail

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

Hides javafx.scene.control.ToggleButton.DEFAULT_STYLE_CLASS.

Constructor Detail

RadioButtonback to summary
public RadioButton()

Creates a radio button with an empty string for its label.

RadioButtonback to summary
public RadioButton(String text)

Creates a radio button with the specified text as its label.

Parameters
text:String

A text string for its label.

Method Detail

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.ToggleButton.createDefaultSkin.

Doc from javafx.scene.control.ToggleButton.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()

Overrides javafx.scene.control.ToggleButton.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.

Annotations
@Override
getInitialAlignmentback to summary
protected Pos getInitialAlignment()

Overrides javafx.scene.control.ToggleButton.getInitialAlignment.

Returns the initial alignment state of this control, for use by the JavaFX CSS engine to correctly set its initial value. This method is overridden to use Pos.CENTER_LEFT initially.

Annotations
@Override
Since
9
initializeback to summary
private void initialize()

Hides javafx.scene.control.ToggleButton.initialize.

queryAccessibleAttributeback to summary
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.ToggleButton.queryAccessibleAttribute.

Doc from javafx.scene.control.ToggleButton.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