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 Details

    • selected

      public final BooleanProperty selectedProperty
      Returns the selected property
  • Constructor Details

    • 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 Details

    • 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.
    • createDefaultSkin

      protected Skin<?> createDefaultSkin()
      Overrides:
      createDefaultSkin in class Control
    • getUserAgentStylesheet

      public String getUserAgentStylesheet()
      Overrides:
      getUserAgentStylesheet in class Region