Class WCardPanel
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WPanel
io.github.cottonmc.cotton.gui.widget.WCardPanel
Similar to the CardLayout in AWT, this panel displays one widget at a time from a list of widgets.
- Since:
- 3.0.0
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a card to this panel without resizing it.void
Adds a card to this panel and resizes it.void
Adds a card to this panel without resizing it.void
Adds a card to this panel and resizes it.void
Adds the default background painters to this widget and all children.int
Gets the number of cards in this panel.Gets the selected card of this panel.int
Gets the index of the selected card in this panel.void
layout()
Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel.setSelectedCard
(WWidget selectedCard) Sets the selected card of this panel.setSelectedIndex
(int selectedIndex) Sets the selected index of this panel.void
setSize
(int x, int y) Sets the size of this widget.void
Creates component peers and initializes animation data for this Widget and all its children.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WPanel
canResize, expandToFit, expandToFit, getBackgroundPainter, hit, onHidden, onShown, paint, remove, setBackgroundPainter, setHost, streamChildren, tick, toString
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
-
WCardPanel
public WCardPanel()
-
-
Method Details
-
add
Adds a card to this panel without resizing it.- Parameters:
card
- the added card
-
add
Adds a card to this panel without resizing it.- Parameters:
index
- the index of the cardcard
- the added card
-
add
Adds a card to this panel and resizes it.- Parameters:
card
- the added cardwidth
- the new widthheight
- the new height
-
add
Adds a card to this panel and resizes it.- Parameters:
index
- the index of the cardcard
- the added cardwidth
- the new widthheight
- the new height
-
getSelectedIndex
public int getSelectedIndex()Gets the index of the selected card in this panel.- Returns:
- the selected card's index
-
setSelectedIndex
Sets the selected index of this panel.- Parameters:
selectedIndex
- the new selected index- Returns:
- this panel
- Throws:
IndexOutOfBoundsException
- if this panel does not contain the card index
-
getSelectedCard
Gets the selected card of this panel.- Returns:
- the selected card
-
setSelectedCard
Sets the selected card of this panel.- Parameters:
selectedCard
- the new selected card- Returns:
- this panel
- Throws:
NoSuchElementException
- if this panel does not contain the card
-
getCardCount
public int getCardCount()Gets the number of cards in this panel.- Returns:
- the card count
- Since:
- 3.1.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)
. -
layout
public void layout()Description copied from class:WPanel
Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel. -
validate
Creates component peers and initializes animation data for this Widget and all its children. The host screen handler must clear any heavyweight peers from its records before this method is called.This method must be called on the root panel of any screen once the widgets have been initialized.
Subclasses should call
super.validate(c)
to ensure that children are validated.- Overrides:
validate
in classWPanel
- Parameters:
c
- the host GUI description- Throws:
IllegalStateException
- if this panel has no cards
-
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
-