Class ToggleButton

java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.component.ToggleButton

public class ToggleButton extends Pane
A button that toggles between an enabled and disabled state.
Since:
0.5.0
  • Constructor Details

    • ToggleButton

      public ToggleButton(int length, int height, @NotNull @NotNull Pane.Priority priority, boolean enabled, @NotNull @NotNull Plugin plugin)
      Creates a new toggle button
      Parameters:
      length - the length
      height - the height
      priority - the priority
      enabled - whether the button should start in its enabled or disabled state
      plugin - the plugin that will be the owner of this button's items
      Since:
      0.12.0
    • ToggleButton

      public ToggleButton(int length, int height, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull Plugin plugin)
      Creates a new toggle button
      Parameters:
      length - the length
      height - the height
      priority - the priority
      plugin - the plugin that will be the owner of this button's items
      Since:
      0.10.8
    • ToggleButton

      public ToggleButton(int length, int height, boolean enabled, @NotNull @NotNull Plugin plugin)
      Creates a new toggle button
      Parameters:
      length - the length
      height - the height
      enabled - whether the button should start in its enabled or disabled state
      plugin - the plugin that will be the owner of this button's items
      Since:
      0.12.0
    • ToggleButton

      public ToggleButton(int length, int height, @NotNull @NotNull Plugin plugin)
      Creates a new toggle button
      Parameters:
      length - the length
      height - the height
      plugin - the plugin that will be the owner of this button's items
      Since:
      0.12.0
    • ToggleButton

      public ToggleButton(int length, int height, @NotNull @NotNull Pane.Priority priority, boolean enabled)
      Creates a new toggle button
      Parameters:
      length - the length
      height - the height
      priority - the priority
      enabled - whether the button should start in its enabled or disabled state
      Since:
      0.12.0
    • ToggleButton

      public ToggleButton(int length, int height, @NotNull @NotNull Pane.Priority priority)
      Creates a new toggle button
      Parameters:
      length - the length
      height - the height
      priority - the priority
      Since:
      0.12.0
    • ToggleButton

      public ToggleButton(int length, int height, boolean enabled)
      Creates a new toggle button
      Parameters:
      length - the length
      height - the height
      enabled - whether the button should start in its enabled or disabled state
      Since:
      0.12.0
    • ToggleButton

      public ToggleButton(int length, int height)
      Creates a new toggle button
      Parameters:
      length - the length
      height - the height
      Since:
      0.12.0
  • Method Details

    • display

      @NotNull public @NotNull GuiItemContainer display()
      Description copied from class: Pane
      Returns a GuiItemContainer with all the items that should be displayed of this pane.
      Specified by:
      display in class Pane
      Returns:
      a container containing all the items to be displayed
    • click

      public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull GuiComponent guiComponent, @NotNull @NotNull InventoryClickEvent event, @NotNull @NotNull Slot slot)
      Description copied from class: Pane
      Called whenever there is being clicked on this pane
      Specified by:
      click in class Pane
      Parameters:
      gui - the gui in which was clicked
      guiComponent - the gui component in which this pane resides
      event - the event that occurred while clicking on this item
      slot - the slot that was clicked in
      Returns:
      whether the item was found or not
    • copy

      @NotNull @Contract(pure=true) public @NotNull ToggleButton copy()
      Description copied from class: Pane
      Makes a copy of this pane and returns it. This makes a deep copy of the pane. This entails that the underlying panes and/or items will be copied as well. The returned pane will never be reference equal to the current pane.
      Overrides:
      copy in class Pane
      Returns:
      a copy of this pane
    • setLength

      public void setLength(int length)
      Description copied from class: Pane
      Set the length of this pane
      Overrides:
      setLength in class Pane
      Parameters:
      length - the new length
    • setHeight

      public void setHeight(int height)
      Description copied from class: Pane
      Set the height of this pane
      Overrides:
      setHeight in class Pane
      Parameters:
      height - the new height
    • setDisabledItem

      public void setDisabledItem(@NotNull @NotNull GuiItem item)
      Sets the item to use when the button is set to disabled
      Parameters:
      item - the disabled item
      Since:
      0.5.0
    • setEnabledItem

      public void setEnabledItem(@NotNull @NotNull GuiItem item)
      Sets the item to use when the button is set to enabled
      Parameters:
      item - the enabled item
      Since:
      0.5.0
    • getItems

      @NotNull public @NotNull Collection<GuiItem> getItems()
      Description copied from class: Pane
      Gets all the items in this pane and all underlying panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.)
      Specified by:
      getItems in class Pane
      Returns:
      all items
    • getPanes

      @NotNull public @NotNull Collection<Pane> getPanes()
      Description copied from class: Pane
      Gets all the panes in this panes, including any child panes from other panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.)
      Specified by:
      getPanes in class Pane
      Returns:
      all panes
    • allowToggle

      public void allowToggle(boolean allowToggle)
      Sets whether this toggle button can be toggled. This only prevents players from toggling the button and does not prevent toggling the button programmatically with methods such as toggle().
      Parameters:
      allowToggle - whether this button can be toggled
      Since:
      0.10.8
    • isEnabled

      @Contract(pure=true) public boolean isEnabled()
      Gets whether this toggle button is currently enabled or disabled.
      Returns:
      whether the button is enabled or disabled
      Since:
      0.9.6
    • toggle

      public void toggle()
      Toggles between the enabled and disabled states
      Since:
      0.5.0
    • clear

      public void clear()
      Description copied from class: Pane
      Clears the entire pane of any items/panes. Underlying panes will not be cleared.
      Specified by:
      clear in class Pane
    • load

      @NotNull @Contract(pure=true) public static @NotNull ToggleButton load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin)
      Loads a toggle button from an XML element
      Parameters:
      instance - the instance class
      element - the element
      plugin - the plugin that will be the owner of the underlying items
      Returns:
      the toggle button
      Since:
      0.10.8