Class WScrollPanel


public class WScrollPanel extends WPanel
Similar to the JScrollPane in Swing, this widget represents a scrollable widget.
Since:
2.0.0
  • Field Details

    • horizontalScrollBar

      protected WScrollBar horizontalScrollBar
      The horizontal scroll bar of this panel.
    • verticalScrollBar

      protected WScrollBar verticalScrollBar
      The vertical scroll bar of this panel.
  • Constructor Details

    • WScrollPanel

      public WScrollPanel(WWidget widget)
      Creates a vertically scrolling panel.
      Parameters:
      widget - the viewed widget
  • Method Details

    • getHorizontalScrollBar

      public WScrollBar getHorizontalScrollBar()
      Returns this scroll panel's horizontal scroll bar.
      Returns:
      the horizontal scroll bar
      Since:
      9.1.0
    • setHorizontalScrollBar

      public WScrollPanel setHorizontalScrollBar(WScrollBar horizontalScrollBar)
      Sets this scroll panel's horizontal scroll bar.
      Parameters:
      horizontalScrollBar - the new horizontal scroll bar
      Returns:
      this scroll panel
      Throws:
      NullPointerException - if the horizontalScrollBar is null
      Since:
      9.1.0
    • isScrollingHorizontally

      public net.fabricmc.fabric.api.util.TriState isScrollingHorizontally()
      Returns whether this scroll panel has a horizontal scroll bar.
      Returns:
      true if there is a horizontal scroll bar, default if a scroll bar should be added if needed, and false otherwise
    • setScrollingHorizontally

      public WScrollPanel setScrollingHorizontally(net.fabricmc.fabric.api.util.TriState scrollingHorizontally)
    • getVerticalScrollBar

      public WScrollBar getVerticalScrollBar()
      Returns this scroll panel's vertical scroll bar.
      Returns:
      the vertical scroll bar
      Since:
      9.1.0
    • setVerticalScrollBar

      public WScrollPanel setVerticalScrollBar(WScrollBar verticalScrollBar)
      Sets this scroll panel's vertical scroll bar.
      Parameters:
      verticalScrollBar - the new vertical scroll bar
      Returns:
      this scroll panel
      Throws:
      NullPointerException - if the verticalScrollBar is null
      Since:
      9.1.0
    • isScrollingVertically

      public net.fabricmc.fabric.api.util.TriState isScrollingVertically()
      Returns whether this scroll panel has a vertical scroll bar.
      Returns:
      true if there is a vertical scroll bar, * default if a scroll bar should be added if needed, * and false otherwise
    • setScrollingVertically

      public WScrollPanel setScrollingVertically(net.fabricmc.fabric.api.util.TriState scrollingVertically)
    • paint

      @Environment(CLIENT) public void paint(DrawContext context, int x, int y, int mouseX, int mouseY)
      Description copied from class: WWidget
      Paints this widget.
      Overrides:
      paint in class WPanel
      Parameters:
      context - the draw context
      x - this widget's X coordinate on the screen
      y - this widget's Y coordinate on the screen
      mouseX - the X coordinate of the cursor
      mouseY - the X coordinate of the cursor
    • 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
    • onMouseScroll

      public InputResult onMouseScroll(int x, int y, double horizontalAmount, double verticalAmount)
      Description copied from class: WWidget
      Notifies this widget that the mouse has been scrolled inside its bounds.
      Overrides:
      onMouseScroll in class WWidget
      Parameters:
      x - The X coordinate of the event, in widget-space (0 is the left edge of this widget)
      y - The Y coordinate of the event, in widget-space (0 is the top edge of this widget)
      horizontalAmount - The scrolled horizontal amount. Positive values are right and negative values are left.
      verticalAmount - The scrolled vertical amount. Positive values are up and negative values are down.
      Returns:
      InputResult.PROCESSED if the event is handled, InputResult.IGNORED otherwise.
    • validate

      public void validate(GuiDescription c)
      Description copied from class: WPanel
      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
    • getInsets

      public Insets getInsets()
      Returns the layout insets used for the viewed widget.
      Returns:
      the layout insets used for the viewed widget
      Since:
      9.1.0
    • setInsets

      public WScrollPanel setInsets(Insets insets)
      Sets the layout insets used for the viewed widget.
      Parameters:
      insets - the layout insets
      Returns:
      this scroll panel
      Since:
      9.1.0