Package swingtree.api
Interface Layout
- All Known Implementing Classes:
Layout.BorderLayoutInstaller
,Layout.ForBoxLayout
,Layout.ForFlowLayout
,Layout.ForMigLayout
,Layout.GridLayoutInstaller
,Layout.None
,Layout.Unspecific
@Immutable
public interface Layout
An abstract representation of an immutable layout configuration for a specific component,
for which layout manager specific implementations can be instantiated through
various factory methods like
border()
, flow()
, grid(int, int)
...
and then supplied to the style API through ComponentStyleDelegate.layout(Layout)
so that the layout can then be installed onto a component dynamically.
The various layout types hold necessary information
and implementation logic required for installing the layout onto a component
through the installFor(JComponent)
method,
which will be used by the style engine of SwingTree
every time the layout object state changes compared to the previous state
effectively making the layout mechanics of a component fully dynamic.
You may implement this interface to create custom layout configurations
for other kinds of LayoutManager
implementations.
This interface also contains various implementations
for supporting the most common types of LayoutManager
s.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
TheLayout.BorderLayoutInstaller
layout is a layout that represents aBorderLayout
layout configuration for a component, which consists of the horizontal gap and vertical gap.static final class
TheLayout.ForBoxLayout
layout is a layout that represents aBoxLayout
layout configuration for a component, which consists of the axis.static final class
TheLayout.ForFlowLayout
layout is a layout that represents aFlowLayout
layout configuration for a component.static final class
TheLayout.ForMigLayout
layout is a layout that represents aMigLayout
layout configuration for a component.static final class
TheLayout.GridLayoutInstaller
layout is a layout that represents aGridLayout
layout configuration for a component, which consists of the number of rows, number of columns, horizontal gap and vertical gap.static final class
TheLayout.None
layout is a layout that represents the absence of aLayoutManager
for a component.static final class
TheLayout.Unspecific
layout is a layout that represents the lack of a specific layout being set for a component. -
Method Summary
Modifier and TypeMethodDescriptionstatic Layout
border()
A factory method for creating a layout that installs theBorderLayout
onto a component based on the supplied parameters.static Layout
border
(int horizontalGap, int verticalGap) A factory method for creating a layout that installs theBorderLayout
onto a component based on the supplied parameters.static Layout
box()
static Layout
boolean
static Layout
flow()
Creates a layout that installs theFlowLayout
with a default alignment ofUI.HorizontalAlignment.CENTER
and a default gap of 5 pixels.static Layout
flow
(UI.HorizontalAlignment align) A factory method for creating a layout that installs theFlowLayout
onto a component based on the supplied parameters.static Layout
flow
(UI.HorizontalAlignment align, int hgap, int vgap) A factory method for creating a layout that installs theFlowLayout
onto a component based on the supplied parameters.static Layout
grid
(int rows, int cols) A factory method for creating a layout that installs theGridLayout
onto a component based on the supplied parameters.static Layout
grid
(int rows, int cols, int horizontalGap, int verticalGap) A factory method for creating a layout that installs theGridLayout
onto a component based on the supplied parameters.int
hashCode()
void
installFor
(JComponent component) Installs this layout for the supplied component.static Layout
A factory method for creating a layout that installs theMigLayout
manager onto a component based on the supplied parameters.static Layout
A factory method for creating a layout that installs theMigLayout
manager onto a component based on the supplied parameters.static Layout
This leads to the installation of theMigLayout
layout manager, which is a powerful general purpose layout manager for Swing.static Layout
none()
If you don't want to assign any layout to a component style, but you also don't want to pass null to theComponentStyleDelegate.layout(Layout)
method, you can use the no-op instance returned by this method.static Layout
A factory method for creating a layout that does nothing (i.e.
-
Method Details
-
hashCode
int hashCode() -
equals
-
installFor
Installs this layout for the supplied component.- Parameters:
component
- The component to install this layout for.
-
unspecific
A factory method for creating a layout that does nothing (i.e. it does not install any layout for a component). This is a no-op layout that can be used to represent the lack of a specific layout being set for a component without having to set the layout tonull
.- Returns:
- A layout that does nothing, i.e. it does not install any layout for a component.
-
none
If you don't want to assign any layout to a component style, but you also don't want to pass null to theComponentStyleDelegate.layout(Layout)
method, you can use the no-op instance returned by this method.- Returns:
- A layout that removes any existing layout from a component.
-
mig
This leads to the installation of theMigLayout
layout manager, which is a powerful general purpose layout manager for Swing. Click here for more information.- Parameters:
constr
- The layout constraints for the layout.rowConstr
- The row constraints for the layout.colConstr
- The column constraints for the layout.- Returns:
- A layout that uses the MigLayout.
-
mig
A factory method for creating a layout that installs theMigLayout
manager onto a component based on the supplied parameters. The MigLayout layout manager is a powerful general purpose layout manager for Swing. Click here for more information.- Parameters:
constr
- The layout constraints for the layout.rowConstr
- The row constraints for the layout.- Returns:
- A layout that uses the MigLayout.
-
mig
A factory method for creating a layout that installs theMigLayout
manager onto a component based on the supplied parameters. This will effectively translate to a call to theMigLayout(String)
constructor with the supplied constraints. In case you are not familiar with the MigLayout constraints, you can find more information about them here.- Parameters:
constr
- The layout constraints for the layout.- Returns:
- A layout that uses the MigLayout.
-
flow
A factory method for creating a layout that installs theFlowLayout
onto a component based on the supplied parameters.- Parameters:
align
- The alignment for the layout, which has to be one ofhgap
- The horizontal gap for the layout.vgap
- The vertical gap for the layout.- Returns:
- A layout that installs the
FlowLayout
onto a component.
-
flow
A factory method for creating a layout that installs theFlowLayout
onto a component based on the supplied parameters.- Parameters:
align
- The alignment for the layout, which has to be one of- Returns:
- A layout that installs the
FlowLayout
onto a component.
-
flow
Creates a layout that installs theFlowLayout
with a default alignment ofUI.HorizontalAlignment.CENTER
and a default gap of 5 pixels.- Returns:
- A layout that installs the
FlowLayout
onto a component.
-
border
A factory method for creating a layout that installs theBorderLayout
onto a component based on the supplied parameters.- Parameters:
horizontalGap
- The horizontal gap for the layout.verticalGap
- The vertical gap for the layout.- Returns:
- A layout that installs the
BorderLayout
onto a component.
-
border
A factory method for creating a layout that installs theBorderLayout
onto a component based on the supplied parameters. The installed layout will have a default gap of 0 pixels.- Returns:
- A layout that installs the
BorderLayout
onto a component.
-
grid
A factory method for creating a layout that installs theGridLayout
onto a component based on the supplied parameters.- Parameters:
rows
- The number of rows for the layout.cols
- The number of columns for the layout.horizontalGap
- The horizontal gap for the layout.verticalGap
- The vertical gap for the layout.- Returns:
- A layout that installs the
GridLayout
onto a component.
-
grid
A factory method for creating a layout that installs theGridLayout
onto a component based on the supplied parameters. The installed layout will have a default gap of 0 pixels.- Parameters:
rows
- The number of rows for the layout.cols
- The number of columns for the layout.- Returns:
- A layout that installs the
GridLayout
onto a component.
-
box
A factory method for creating a layout that installs theBoxLayout
onto a component based on the suppliedUI.Axis
parameter. The axis determines whether the layout will be a horizontal or verticalBoxLayout
.- Parameters:
axis
- The axis for the layout, which has to be one of- Returns:
- A layout that installs the
BoxLayout
onto a component.
-
box
A factory method for creating a layout that installs theBoxLayout
onto a component with a default axis ofUI.Axis.X
.- Returns:
- A layout that installs the default
BoxLayout
onto a component.
-