Class WTabPanel
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WPanel
io.github.cottonmc.cotton.gui.widget.WTabPanel
A panel that contains creative inventory-style tabs on the top.
- Since:
- 3.0.0
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(WTabPanel.Tab tab) Adds a tab to this panel.void
add
(WWidget widget, Consumer<WTabPanel.Tab.Builder> configurator) Configures and adds a tab to this panel.void
Adds the default background painters to this widget and all children.int
Returns the index of the currently open tab.Returns the currently open tab's data.int
Returns the number of tabs in this tab panel.setSelectedIndex
(int tabIndex) Sets the currently open tab by its index.Sets the currently open tab to the providedWTabPanel.Tab
.void
setSize
(int x, int y) Sets the size of this widget.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WPanel
canResize, expandToFit, expandToFit, getBackgroundPainter, hit, layout, onHidden, onShown, paint, remove, setBackgroundPainter, setHost, streamChildren, tick, toString, validate
Methods inherited from class io.github.cottonmc.cotton.gui.widget.WWidget
addNarrations, addTooltip, canFocus, canHover, getAbsoluteX, getAbsoluteY, getFocusModel, getHeight, getHost, getParent, getWidth, getX, getY, hoveredProperty, isActivationKey, isFocused, isHovered, isNarratable, isWithinBounds, onCharTyped, onClick, onFocusGained, onFocusLost, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, releaseFocus, renderTooltip, requestFocus, setHovered, setLocation, setParent, shouldRenderInDarkMode
-
Constructor Details
-
WTabPanel
public WTabPanel()Constructs a new tab panel.
-
-
Method Details
-
add
Adds a tab to this panel.- Parameters:
tab
- the added tab
-
add
Configures and adds a tab to this panel.- Parameters:
widget
- the contained widgetconfigurator
- the tab configurator
-
getSelectedTab
Returns the currently open tab's data.- Returns:
- the currently open tab's data
- Since:
- 6.3.0
-
setSelectedTab
Sets the currently open tab to the providedWTabPanel.Tab
.- Parameters:
tab
- the tab to open, cannot be null- Returns:
- this tab panel
- Throws:
NoSuchElementException
- if the tab is not in this panel- Since:
- 6.3.0
-
getSelectedIndex
public int getSelectedIndex()Returns the index of the currently open tab.- Returns:
- the index of the currently open tab
- Since:
- 6.3.0
-
setSelectedIndex
Sets the currently open tab by its index.- Parameters:
tabIndex
- the 0-based index of the tab to select, in order of adding- Returns:
- this tab panel
- Throws:
IndexOutOfBoundsException
- if the tab index is invalid for this tab panel- Since:
- 6.3.0
-
getTabCount
public int getTabCount()Returns the number of tabs in this tab panel.- Returns:
- the number of tabs in this tab panel
- Since:
- 6.3.0
-
setSize
public void setSize(int x, int y) Description copied from class:WWidget
Sets the size of this widget.Overriding methods may restrict one of the dimensions to be a constant value, for example
super.setSize(x, 20)
. -
addPainters
@Environment(CLIENT) public void addPainters()Description copied from class:WPanel
Adds the default background painters to this widget and all children.Always called before
GuiDescription.addPainters()
to allow users to modify painters.Subclasses should call
super.addPainters()
to ensure that children have proper default painters.- Overrides:
addPainters
in classWPanel
-