Class RadioButton

  • All Implemented Interfaces:
    Styleable, EventTarget, Skinnable, Toggle

    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 ActionEvent is sent. Your application can perform some action based on this event by implementing an EventHandler to process the 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");
     RadioButton button2 = new RadioButton("select second");
    Image of the RadioButton control
    JavaFX 2.0
    • Constructor Detail

      • RadioButton

        public RadioButton()
        Creates a radio button with an empty string for its label.
      • RadioButton

        public RadioButton​(String text)
        Creates a radio button with the specified text as its label.
        text - A text string for its label.
    • Method Detail

      • fire

        public 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.
        fire in class ToggleButton
      • createDefaultSkin

        protected Skin<?> 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(...).
        createDefaultSkin in class ToggleButton
        new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.
      • getInitialAlignment

        protected Pos 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.
        getInitialAlignment in class ToggleButton
        the initial alignment state of this control
      • queryAccessibleAttribute

        public Object queryAccessibleAttribute​(AccessibleAttribute attribute,
                                               Object... parameters)
        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.

        queryAccessibleAttribute in class ToggleButton
        attribute - the requested attribute
        parameters - optional list of parameters
        the value for the requested attribute
        See Also: