Class ToggleButton

All Implemented Interfaces:
LayoutMeasurable, LayoutMeasurableMixin, HasAlignmentProperty, HasBackgroundProperty, HasBlendModeProperty, HasBorderProperty, HasClipProperty, HasEffectProperty, HasFontProperty, HasGraphicProperty, HasHeightProperty, HasImageUrlProperty, HasLayoutXProperty, HasLayoutYProperty, HasManagedProperty, HasMaxHeightProperty, HasMaxWidthProperty, HasMinHeightProperty, HasMinWidthProperty, HasMouseTransparentProperty, HasOnMouseClickedProperty, HasOpacityProperty, HasPaddingProperty, HasParentProperty, HasPrefHeightProperty, HasPrefWidthProperty, HasSnapToPixelProperty, HasTextAlignmentProperty, HasTextFillProperty, HasTextProperty, HasVisibleProperty, HasWidthProperty, Styleable, EventTarget, Skinnable, Toggle, INode, PreferenceResizableNode
Direct Known Subclasses:
RadioButton

public class ToggleButton extends ButtonBase implements Toggle
Author:
Bruno Salmon
  • Property Details

  • Constructor Details

    • ToggleButton

      public ToggleButton()
      Creates a toggle button with an empty string for its label.
    • ToggleButton

      public ToggleButton(String text)
      Creates a toggle button with the specified text as its label.
      Parameters:
      text - A text string for its label.
    • ToggleButton

      public ToggleButton(String text, Node graphic)
      Creates a toggle button with the specified text and icon for its label.
      Parameters:
      text - A text string for its label.
      graphic - the icon for its label.
  • Method Details

    • initialize

      protected void initialize()
    • setSelected

      public final void setSelected(boolean value)
      Sets the value of the selected property.
      Specified by:
      setSelected in interface Toggle
      Property description:
      Indicates whether this toggle button is selected. This can be manipulated programmatically.
      Parameters:
      value - the value for the selected property
      See Also:
    • isSelected

      public final boolean isSelected()
      Gets the value of the selected property.
      Specified by:
      isSelected in interface Toggle
      Property description:
      Indicates whether this toggle button is selected. This can be manipulated programmatically.
      Returns:
      the value of the selected property
      See Also:
    • selectedProperty

      public final BooleanProperty selectedProperty()
      Indicates whether this toggle button is selected. This can be manipulated programmatically.
      Specified by:
      selectedProperty in interface Toggle
      Returns:
      the selected property
      See Also:
    • setToggleGroup

      public final void setToggleGroup(ToggleGroup value)
      Sets the value of the toggleGroup property.
      Specified by:
      setToggleGroup in interface Toggle
      Property description:
      The ToggleGroup to which this ToggleButton belongs. A ToggleButton can only be in one group at any one time. If the group is changed, then the button is removed from the old group prior to being added to the new group.
      Parameters:
      value - the value for the toggleGroup property
      See Also:
    • getToggleGroup

      public final ToggleGroup getToggleGroup()
      Gets the value of the toggleGroup property.
      Specified by:
      getToggleGroup in interface Toggle
      Property description:
      The ToggleGroup to which this ToggleButton belongs. A ToggleButton can only be in one group at any one time. If the group is changed, then the button is removed from the old group prior to being added to the new group.
      Returns:
      the value of the toggleGroup property
      See Also:
    • toggleGroupProperty

      public final ObjectProperty<ToggleGroup> toggleGroupProperty()
      The ToggleGroup to which this ToggleButton belongs. A ToggleButton can only be in one group at any one time. If the group is changed, then the button is removed from the old group prior to being added to the new group.
      Specified by:
      toggleGroupProperty in interface Toggle
      Returns:
      the toggleGroup property
      See Also:
    • fire

      public void fire()
      Invoked when a user gesture indicates that an event for this ButtonBase should occur.

      If invoked, this method will be executed regardless of the status of ButtonBase.arm().

      Specified by:
      fire in class ButtonBase
    • createDefaultSkin

      protected Skin<?> createDefaultSkin()
      Description copied from class: Control
      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(...).
      Overrides:
      createDefaultSkin in class Control
      Returns:
      new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.