public class WBox extends WPanelWithInsets
Similar to the BoxLayout in Swing, this widget represents a list of widgets along an axis.
Since:
2.0.0
  • Field Details

    • spacing

      protected int spacing
      The spacing between widgets.
    • axis

      protected Axis axis
      The axis that the widgets are laid out on.
    • horizontalAlignment

      protected HorizontalAlignment horizontalAlignment
      The horizontal alignment for this box's children.
      Since:
      2.1.0
    • verticalAlignment

      protected VerticalAlignment verticalAlignment
      The vertical alignment for this box's children.
      Since:
      2.1.0
  • Constructor Details

    • WBox

      public WBox(Axis axis)
      Constructs a box.
      Parameters:
      axis - the box axis
      Throws:
      NullPointerException - if the axis is null
  • Method Details

    • add

      public void add(WWidget widget, int width, int height)
      Adds a widget to this box. If the widget is resizeable, resizes it to the provided dimensions.
      Parameters:
      widget - the widget
      width - the new width of the widget
      height - the new height of the widget
    • add

      public void add(WWidget widget)
      Adds a widget to this box. If the widget is resizeable, resizes it to 18x18.
      Parameters:
      widget - the widget
    • 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
    • getSpacing

      public int getSpacing()
      Gets the spacing between widgets.
      Returns:
      the spacing
    • setSpacing

      public WBox setSpacing(int spacing)
      Sets the spacing between widgets in this box.
      Parameters:
      spacing - the new spacing
      Returns:
      this box
    • getAxis

      public Axis getAxis()
      Gets the axis of this box.
      Returns:
      the axis
    • setAxis

      public WBox setAxis(Axis axis)
      Sets the axis of this box.
      Parameters:
      axis - the new axis
      Returns:
      this box
      Throws:
      NullPointerException - if the axis is null
    • getHorizontalAlignment

      public HorizontalAlignment getHorizontalAlignment()
      Gets the horizontal alignment of this box.
      Returns:
      the alignment
      Since:
      2.1.0
    • setHorizontalAlignment

      public WBox setHorizontalAlignment(HorizontalAlignment alignment)
      Sets the horizontal alignment of this box.
      Parameters:
      alignment - the new alignment
      Returns:
      this box
      Throws:
      NullPointerException - if the alignment is null
      Since:
      2.1.0
    • getVerticalAlignment

      public VerticalAlignment getVerticalAlignment()
      Gets the vertical alignment of this box.
      Returns:
      the alignment
      Since:
      2.1.0
    • setVerticalAlignment

      public WBox setVerticalAlignment(VerticalAlignment alignment)
      Sets the vertical alignment of this box.
      Parameters:
      alignment - the new alignment
      Returns:
      this box
      Throws:
      NullPointerException - if the alignment is null
      Since:
      2.1.0
    • setInsets

      public WBox 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