Class ToggleSwitch

  • All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    public class ToggleSwitch
    extends Labeled
    Much like a Toggle Button this control allows the user to toggle between one of two states. It has been popularized in touch based devices where its usage is particularly useful because unlike a checkbox the finger touch of a user doesn't obscure the control.

    Shown below is a screenshot of the ToggleSwitch control in its on and off state:

    Screenshot of ToggleSwitch
    • Property Detail

      • selected

        public final BooleanProperty selectedProperty
        Returns the selected property
    • Constructor Detail

      • ToggleSwitch

        public ToggleSwitch()
        Creates a toggle switch with empty string for its label.
      • ToggleSwitch

        public ToggleSwitch​(String text)
        Creates a toggle switch with the specified label.
        Parameters:
        text - The label string of the control.
    • Method Detail

      • setSelected

        public final void setSelected​(boolean value)
        Sets the selected value of this Toggle Switch
      • isSelected

        public final boolean isSelected()
        Returns whether this Toggle Switch is selected
      • selectedProperty

        public final BooleanProperty selectedProperty()
        Returns the selected property
      • fire

        public void fire()
        Toggles the state of the ToggleSwitch. The ToggleSwitch will cycle through the selected and unselected states.