Class WCardPanel


public class WCardPanel extends WPanel
Similar to the CardLayout in AWT, this panel displays one widget at a time from a list of widgets.
Since:
3.0.0
  • Constructor Details

    • WCardPanel

      public WCardPanel()
  • Method Details

    • add

      public void add(WWidget card)
      Adds a card to this panel without resizing it.
      Parameters:
      card - the added card
    • add

      public void add(int index, WWidget card)
      Adds a card to this panel without resizing it.
      Parameters:
      index - the index of the card
      card - the added card
    • add

      public void add(WWidget card, int width, int height)
      Adds a card to this panel and resizes it.
      Parameters:
      card - the added card
      width - the new width
      height - the new height
    • add

      public void add(int index, WWidget card, int width, int height)
      Adds a card to this panel and resizes it.
      Parameters:
      index - the index of the card
      card - the added card
      width - the new width
      height - the new height
    • getSelectedIndex

      public int getSelectedIndex()
      Gets the index of the selected card in this panel.
      Returns:
      the selected card's index
    • setSelectedIndex

      public WCardPanel setSelectedIndex(int selectedIndex)
      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

      public WWidget getSelectedCard()
      Gets the selected card of this panel.
      Returns:
      the selected card
    • setSelectedCard

      public WCardPanel setSelectedCard(WWidget selectedCard)
      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).

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

      public void validate(GuiDescription c)
      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 class WPanel
      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 class WPanel