Class ToggleButton
java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.component.ToggleButton
A button that toggles between an enabled and disabled state.
- Since:
- 0.5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class Pane
Pane.Priority -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionToggleButton(int length, int height) Creates a new toggle buttonToggleButton(int length, int height, boolean enabled) Creates a new toggle buttonToggleButton(int length, int height, boolean enabled, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton(int length, int height, @NotNull Pane.Priority priority) Creates a new toggle buttonToggleButton(int length, int height, @NotNull Pane.Priority priority, boolean enabled) Creates a new toggle buttonToggleButton(int length, int height, @NotNull Pane.Priority priority, boolean enabled, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton(int length, int height, @NotNull Pane.Priority priority, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton(int length, int height, @NotNull Plugin plugin) Creates a new toggle button -
Method Summary
Modifier and TypeMethodDescriptionvoidallowToggle(boolean allowToggle) Sets whether this toggle button can be toggled.voidclear()Clears the entire pane of any items/panes.booleanclick(@NotNull Gui gui, @NotNull GuiComponent guiComponent, @NotNull InventoryClickEvent event, @NotNull Slot slot) Called whenever there is being clicked on this pane@NotNull ToggleButtoncopy()Makes a copy of this pane and returns it.@NotNull GuiItemContainerdisplay()Returns aGuiItemContainerwith all the items that should be displayed of this pane.@NotNull Collection<GuiItem> getItems()Gets all the items in this pane and all underlying panes.@NotNull Collection<Pane> getPanes()Gets all the panes in this panes, including any child panes from other panes.booleanGets whether this toggle button is currently enabled or disabled.static @NotNull ToggleButtonLoads a toggle button from an XML elementvoidsetDisabledItem(@NotNull GuiItem item) Sets the item to use when the button is set to disabledvoidsetEnabledItem(@NotNull GuiItem item) Sets the item to use when the button is set to enabledvoidsetHeight(int height) Set the height of this panevoidsetLength(int length) Set the length of this panevoidtoggle()Toggles between the enabled and disabled statesMethods inherited from class Pane
callOnClick, createBorder, findMatchingItem, getHeight, getLength, getPriority, getUUID, isVisible, load, matchesItem, setOnClick, setPriority, setVisible
-
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 lengthheight- the heightpriority- the priorityenabled- whether the button should start in its enabled or disabled stateplugin- 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 lengthheight- the heightpriority- the priorityplugin- the plugin that will be the owner of this button's items- Since:
- 0.10.8
-
ToggleButton
Creates a new toggle button- Parameters:
length- the lengthheight- the heightenabled- whether the button should start in its enabled or disabled stateplugin- the plugin that will be the owner of this button's items- Since:
- 0.12.0
-
ToggleButton
Creates a new toggle button- Parameters:
length- the lengthheight- the heightplugin- 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 lengthheight- the heightpriority- the priorityenabled- whether the button should start in its enabled or disabled state- Since:
- 0.12.0
-
ToggleButton
Creates a new toggle button- Parameters:
length- the lengthheight- the heightpriority- the priority- Since:
- 0.12.0
-
ToggleButton
public ToggleButton(int length, int height, boolean enabled) Creates a new toggle button- Parameters:
length- the lengthheight- the heightenabled- 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 lengthheight- the height- Since:
- 0.12.0
-
-
Method Details
-
display
Description copied from class:PaneReturns aGuiItemContainerwith all the items that should be displayed of this pane. -
click
public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull GuiComponent guiComponent, @NotNull @NotNull InventoryClickEvent event, @NotNull @NotNull Slot slot) Description copied from class:PaneCalled whenever there is being clicked on this pane -
copy
Description copied from class:PaneMakes 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. -
setLength
-
setHeight
-
setDisabledItem
Sets the item to use when the button is set to disabled- Parameters:
item- the disabled item- Since:
- 0.5.0
-
setEnabledItem
Sets the item to use when the button is set to enabled- Parameters:
item- the enabled item- Since:
- 0.5.0
-
getItems
Description copied from class:PaneGets 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.) -
getPanes
Description copied from class:PaneGets 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.) -
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 astoggle().- 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
-
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 classelement- the elementplugin- the plugin that will be the owner of the underlying items- Returns:
- the toggle button
- Since:
- 0.10.8
-