Class WTabPanel


public class WTabPanel extends WPanel
A panel that contains creative inventory-style tabs on the top.
Since:
3.0.0
  • Constructor Details

    • WTabPanel

      public WTabPanel()
      Constructs a new tab panel.
  • Method Details

    • add

      public void add(WTabPanel.Tab tab)
      Adds a tab to this panel.
      Parameters:
      tab - the added tab
    • add

      public void add(WWidget widget, Consumer<WTabPanel.Tab.Builder> configurator)
      Configures and adds a tab to this panel.
      Parameters:
      widget - the contained widget
      configurator - the tab configurator
    • getSelectedTab

      public WTabPanel.Tab getSelectedTab()
      Returns the currently open tab's data.
      Returns:
      the currently open tab's data
      Since:
      6.3.0
    • setSelectedTab

      @Contract("null -> fail; _ -> this") public WTabPanel setSelectedTab(WTabPanel.Tab tab)
      Sets the currently open tab to the provided WTabPanel.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

      @Contract("_ -> this") public WTabPanel setSelectedIndex(int tabIndex)
      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).

      Overrides:
      setSize in class WWidget
      Parameters:
      x - the new width
      y - the new height
    • 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 class WPanel