Enum Class UniformGridLayout.CollapseEmpty

java.lang.Object
java.lang.Enum<UniformGridLayout.CollapseEmpty>
swingtree.layout.UniformGridLayout.CollapseEmpty
All Implemented Interfaces:
Serializable, Comparable<UniformGridLayout.CollapseEmpty>, Constable
Enclosing class:
UniformGridLayout

public static enum UniformGridLayout.CollapseEmpty extends Enum<UniformGridLayout.CollapseEmpty>
Decides which of the rows and columns that no component occupies a UniformGridLayout leaves out of its grid. The components share the space which the left out rows and columns would have taken up, so they get larger cells.

The grid is filled row by row, so a column is empty when there are fewer components than columns, and a row is empty when the components do not reach it. A component which is not visible still occupies its cell. Here is how a grid declared with 2 rows and 5 columns, in the mode UniformGridLayout.Mode.WRAP_AFTER_COLUMNS, lays out 3 components, as rows × columns: NONE 2 × 5, COLUMNS 2 × 3, ROWS 1 × 5 and ROWS_AND_COLUMNS 1 × 3.

In a container without components, a number of rows or columns which is collapsed is 1, and that single row or column is 0 pixels large, because there is no component to size it after.

See Also:
  • Enum Constant Details

    • NONE

      public static final UniformGridLayout.CollapseEmpty NONE
      Rows and columns are kept, even when no component occupies them. In the mode UniformGridLayout.Mode.WRAP_AFTER_COLUMNS, the cells of a grid therefore keep their size while components are added, until the grid is full.
    • COLUMNS

      public static final UniformGridLayout.CollapseEmpty COLUMNS
      The columns which no component occupies are left out, so the grid never has more columns than components. A grid of 2 rows and 5 columns lays out 3 components in 2 rows of 3 columns, and keeps its empty second row.
    • ROWS

      public static final UniformGridLayout.CollapseEmpty ROWS
      The rows which no component occupies are left out, so the grid only has as many rows as the components fill. A grid of 2 rows and 5 columns lays out 3 components in 1 row of 5 columns, and keeps its 2 empty columns. In the mode UniformGridLayout.Mode.WRAP_AFTER_COLUMNS, the declared number of rows then only makes a difference while the declared number of columns is 0.
    • ROWS_AND_COLUMNS

      public static final UniformGridLayout.CollapseEmpty ROWS_AND_COLUMNS
      The rows and the columns which no component occupies are left out, so no row and no column of the grid is ever empty. A grid of 2 rows and 5 columns lays out 3 components in 1 row of 3 columns, and 8 components in 2 rows of 5 columns. This is the default.
  • Method Details

    • values

      public static UniformGridLayout.CollapseEmpty[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static UniformGridLayout.CollapseEmpty valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null