Class ToggleButton

All Implemented Interfaces:
TextComponent, Serializable

public class ToggleButton extends Button
An implementation of "toggle" button. Behavior the same as checkbox but have not any text.
See Also:
  • Constructor Details

    • ToggleButton

      public ToggleButton(String text, float x, float y, float width, float height)
      Creates a button with specified text and specified position and size.
      Parameters:
      text - button text.
      x - x position in parent.
      y - y position in parent.
      width - width of component.
      height - height of component.
    • ToggleButton

      public ToggleButton()
      Creates toggle button with default bg color and default toggled bg color.
    • ToggleButton

      public ToggleButton(String text)
      Creates toggle button with default bg color, toggled bg color and specified text.
      Parameters:
      text - button text.
    • ToggleButton

      public ToggleButton(float x, float y, float width, float height)
      Creates a button with specified position and size and default bg color and default toggled bg color.
      Parameters:
      x - x position in parent.
      y - y position in parent.
      width - width of component.
      height - height of component.
    • ToggleButton

      public ToggleButton(org.joml.Vector2f position, org.joml.Vector2f size)
      Creates a button with specified position and size and default bg color and default toggled bg color.
      Parameters:
      position - position in parent.
      size - size of component.
  • Method Details

    • isToggled

      public boolean isToggled()
      Returns true if toggle button is toggled.
      Returns:
      true if toggle button is toggled.
    • setToggled

      public void setToggled(boolean toggled)
      Used to change toggled state.
      Parameters:
      toggled - new value.
    • getToggledBackgroundColor

      public org.joml.Vector4f getToggledBackgroundColor()
      Returns background color which will be used as background color if button toggled.
      Returns:
      toggled button color.
    • setToggledBackgroundColor

      public void setToggledBackgroundColor(org.joml.Vector4f toggledBackgroundColor)
      Used to change background color which will be used as background color if button toggled.
      Parameters:
      toggledBackgroundColor - new value.
    • getTogglededBackgroundIcon

      public Icon getTogglededBackgroundIcon()
      Returns toggled background icon.
      Returns:
      toggled background icon.
    • setTogglededBackgroundIcon

      public void setTogglededBackgroundIcon(Icon togglededBackgroundIcon)
      Used to change toggled background icon.
      Parameters:
      togglededBackgroundIcon - toggled background icon.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Button
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Button
    • toString

      public String toString()
      Overrides:
      toString in class Button