public class WBox extends WPanel
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
    • getInsets

      public Insets getInsets()
      Gets the layout insets of this box.
      Returns:
      the insets
      Since:
      4.0.0
    • setInsets

      public WBox setInsets(Insets insets)
      Sets the layout insets of this box.

      The insets should be set before adding any widgets to this box.

      Parameters:
      insets - the insets, should not be null
      Returns:
      this box
      Since:
      4.0.0