Package swingtree.api
Class Layout.ForGridLayout
java.lang.Object
swingtree.api.Layout.ForGridLayout
- All Implemented Interfaces:
Layout
- Enclosing interface:
Layout
A
Layout which installs a UniformGridLayout onto a component, created
through one of the Layout.grid(int, int) factory methods. It consists of the
mode of the grid, which of its empty rows and columns are left out, how it grows when it
holds more children than cells, the numbers of rows and columns, and the horizontal and
vertical gaps.
When the component already has a UniformGridLayout, for example one installed through
UIForAnySwing.withGridLayout(int, int) or by an earlier Layout.ForGridLayout,
that layout manager is updated in place instead of being replaced.
-
Nested Class Summary
Nested classes/interfaces inherited from interface swingtree.api.Layout
Layout.BorderLayoutInstaller, Layout.ForBoxLayout, Layout.ForFlowLayout, Layout.ForGridLayout, Layout.ForMigLayout, Layout.None, Layout.Unspecific -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()voidinstallFor(JComponent component) Installs aUniformGridLayoutwith the settings, the numbers of rows and columns and the gaps of this configuration onto the supplied component.toString()withCollapseEmpty(UniformGridLayout.CollapseEmpty collapseEmpty) Returns a newLayout.ForGridLayoutwhich leaves out the given empty rows and columns, with all other properties copied unchanged.Returns a newLayout.ForGridLayoutwith the given mode and all other properties copied unchanged.withOverflowGrowth(UniformGridLayout.OverflowGrowth overflowGrowth) Returns a newLayout.ForGridLayoutwhich grows an overflowing grid in the given way, with all other properties copied unchanged.
-
Method Details
-
withMode
Returns a newLayout.ForGridLayoutwith the given mode and all other properties copied unchanged. The mode decides how the grid is built from the numbers of rows and columns:UniformGridLayout.Mode.WRAP_AFTER_COLUMNSstarts a new row after every declared number of columns, andUniformGridLayout.Mode.SPREAD_OVER_ROWSspreads the children over the declared rows, like aGridLayout.- Parameters:
mode- How the grid is built from the numbers of rows and columns.- Returns:
- A new
Layout.ForGridLayoutwith the given mode.
-
withCollapseEmpty
Returns a newLayout.ForGridLayoutwhich leaves out the given empty rows and columns, with all other properties copied unchanged. For example, withUniformGridLayout.CollapseEmpty.NONE, 3 children of a grid of 2 rows and 5 columns take the first 3 cells of all 10, and withUniformGridLayout.CollapseEmpty.ROWS_AND_COLUMNSthey share the whole component in a single row of 3 columns.- Parameters:
collapseEmpty- Which of the rows and columns that no child occupies are left out.- Returns:
- A new
Layout.ForGridLayoutwith the given setting.
-
withOverflowGrowth
Returns a newLayout.ForGridLayoutwhich grows an overflowing grid in the given way, with all other properties copied unchanged. A grid overflows when it holds more children than its number of rows times its number of columns: withUniformGridLayout.OverflowGrowth.ADD_ROWS, 13 children of a grid of 2 rows and 5 columns are laid out in 3 rows of 5 columns, withUniformGridLayout.OverflowGrowth.ADD_COLUMNSin 2 rows of 7 columns, and withUniformGridLayout.OverflowGrowth.ADD_ROWS_AND_COLUMNSin 3 rows of 6 columns.- Parameters:
overflowGrowth- How the grid grows when it holds more children than cells.- Returns:
- A new
Layout.ForGridLayoutwith the given setting.
-
hashCode
public int hashCode() -
equals
-
installFor
Installs aUniformGridLayoutwith the settings, the numbers of rows and columns and the gaps of this configuration onto the supplied component. If the component already has aUniformGridLayout, only the properties that differ are updated, andJComponent.revalidate()is called to lay out the component again.- Specified by:
installForin interfaceLayout- Parameters:
component- The component to install theUniformGridLayoutfor.
-
toString
-