Class WGridPanel


public class WGridPanel extends WPanelWithInsets
A panel that positions children in a grid.
  • Field Details

    • grid

      protected int grid
      The grid size in pixels. Defaults to 18, which is the size of one item slot.
    • horizontalGap

      protected int horizontalGap
      The horizontal gap between two grid cells.
      Since:
      6.4.0
    • verticalGap

      protected int verticalGap
      The vertical gap between two grid cells.
      Since:
      6.4.0
  • Constructor Details

    • WGridPanel

      public WGridPanel()
      Constructs a grid panel with the default grid size.
    • WGridPanel

      public WGridPanel(int gridSize)
      Constructs a grid panel with a custom grid size.
      Parameters:
      gridSize - the grid size in pixels
  • Method Details

    • setGaps

      public WGridPanel setGaps(int horizontalGap, int verticalGap)
      Set the gaps between grid cells.

      This method can only be called before any elements get added to this layout.

      Parameters:
      horizontalGap - the horizontal gap between grid cells
      verticalGap - the vertical gap between grid cells
      Since:
      6.4.0
    • add

      public void add(WWidget w, int x, int y)
      Adds a widget to this panel.

      If the widget can be resized, it will be resized to (grid, grid).

      Parameters:
      w - the widget
      x - the X position in grid cells
      y - the Y position in grid cells
    • add

      public void add(WWidget w, int x, int y, int width, int height)
      Adds a widget to this panel and resizes it to a custom size.
      Parameters:
      w - the widget
      x - the X position in grid cells
      y - the Y position in grid cells
      width - the new width in grid cells
      height - the new height in grid cells
    • setInsets

      public WGridPanel setInsets(Insets insets)
      Description copied from class: WPanelWithInsets
      Sets the layout insets of this panel. Subclasses are encouraged to override this method to return their more specific type (such as WGridPanel).

      If there are already widgets in this panel when the insets are modified, the panel is resized and the widgets are moved according to the insets.

      Overrides:
      setInsets in class WPanelWithInsets
      Parameters:
      insets - the insets, should not be null
      Returns:
      this panel