org.gnome.gtk

## Class Box

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.gnome.glib.Object
      - - org.gnome.gtk.Widget
        - - org.gnome.gtk.Container
          - - org.gnome.gtk.Box

- All Implemented Interfaces:
    Orientable
  Direct Known Subclasses:
    ButtonBox, HBox, VBox

      public class Box
      extends Container
      implements Orientable

  Base class for Containers which organize a variable number of Widgets into a rectangular area. This is either a single row of child Widgets (in the case of `HBox`), or a single column (for the case of `VBox`). All the children of a Box are allocated one dimension in common, being the height of a row, or the width of a column, respectively.

  Nested combinations of VBoxes and HBoxes are the cornerstone layout technique used in GTK. A top level VBox to organize a Window is followed by a sequence Widgets, many of which will end up being HBoxes, and each of those in turn might contain further Containers. This sort of thing gives you great flexibility when laying out your user interface.

  Boxes are also used to enable grouping of Widgets at very small scales as well. For example, the ok Button you see in every GNOME dialog is actually an Image holding the icon and a Label with the text "OK" packed into an HBox; the HBox is what was actually added to the Button!

  Since:
    4.0.1
  Author:
    Andrew Cowie

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.gnome.gtk.Widget

      `Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Box(Orientation orientation, int spacing)` Construct a new Box of the given orientation and specifying a default spacing.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Orientation` | `getOrientation()` Get the orientation of this Orientable.
    `int` | `getSpacing()` Returns the amount of spacing that is set to be places between the Widgets that are in the Box.
    `void` | `packEnd(Widget child, boolean expand, boolean fill, int padding)` Add a Widget to the end of the Box.
    `void` | `packStart(Widget child, boolean expand, boolean fill, int padding)` Add a Widget to the beginning of the Box.
    `void` | `reorderChild(Widget child, int position)` Change the position of a Widget in the Box.
    `void` | `setOrientation(Orientation orientation)` Set the orientation of this Orientable.
    `void` | `setSpacing(int spacing)` Set the amount of spacing between the Widgets in the Box.

    - ### Methods inherited from class org.gnome.gtk.Container

      `add, getChildren, remove, setBorderWidth`

    - ### Methods inherited from class org.gnome.gtk.Widget

      `activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll`

    - ### Methods inherited from class org.freedesktop.bindings.Pointer

      `toString`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Box

          public Box(Orientation orientation,
             int spacing)

      Construct a new Box of the given orientation and specifying a default spacing. See also the original Widgets `HBox` and `VBox`.
      Since:
        4.1.1

  - ### Method Detail

    - #### getOrientation

          public Orientation getOrientation()

      Description copied from interface: `Orientable`
      Get the orientation of this Orientable.
      Specified by:
        `getOrientation` in interface `Orientable`

    - #### getSpacing

          public int getSpacing()

      Returns the amount of spacing that is set to be places between the Widgets that are in the Box. The amount is measured in pixels.
      Since:
        4.0.11

    - #### packEnd

          public void packEnd(Widget child,
                     boolean expand,
                     boolean fill,
                     int padding)

      Add a Widget to the end of the Box. The parameters work the same as for `packStart()`, but note that Widgets packed with respect to the end will pack inwards from the end, closer to the middle than Widgets already added with `packEnd()`.
      Since:
        4.0.6

    - #### packStart

          public void packStart(Widget child,
                       boolean expand,
                       boolean fill,
                       int padding)

      Add a Widget to the beginning of the Box. Widget child will be ordered after any other Widgets that have already been packed with respect to the start of the Box, but before any Widgets that are packed at the end of the Box with `packEnd()`.
      Parameters:
        `child` - the Widget to be added
        `expand` - Whether the new `child` is to be given extra space allocated to Box. The extra space will be divided evenly between all children of this Box that were added with `expand` set to `true`.
        `fill` - Whether space given to `child` by the `expand` option is actually allocated to child. If you specify `false` here, then any extra space will pad the Widget, rather than causing it to grow larger.
        `padding` - extra space (in pixels) to put between this child and its neighbours. This is over and above the global amount of padding that was specified by the `spacing` parameter when the Box was constructed. If `child` is the Widget at one of the start of the Box, then `padding` pixels are also put between the Widget and the leading edge.
      Since:
        4.0.1

    - #### reorderChild

          public void reorderChild(Widget child,
                          int position)

      Change the position of a Widget in the Box. The child will still be packed with respect to the beginning (if `packStart()` was used) or end (if `packEnd()` was used) of the Box, and will be placed just after the Widget at `position`.
      Since:
        4.0.8

    - #### setOrientation

          public void setOrientation(Orientation orientation)

      Description copied from interface: `Orientable`
      Set the orientation of this Orientable.
      Specified by:
        `setOrientation` in interface `Orientable`

    - #### setSpacing

          public void setSpacing(int spacing)

      Set the amount of spacing between the Widgets in the Box. The spacing is measured in pixels. By default this is `0`, but is actually whatever was set in the `HBox` or `VBox` constructor.

      Allowed values are `0` or greater.

      Since:
        4.0.11