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 LayoutManagers.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classTheLayout.BorderLayoutInstallerlayout is a layout that represents aBorderLayoutlayout configuration for a component, which consists of the horizontal gap and vertical gap.static final classTheLayout.ForBoxLayoutlayout is a layout that represents aBoxLayoutlayout configuration for a component, which consists of the axis.static final classTheLayout.ForFlowLayoutlayout is a layout that represents aFlowLayoutlayout configuration for a component.static final classTheLayout.ForMigLayoutlayout is a layout that represents aMigLayoutlayout configuration for a component.static final classTheLayout.GridLayoutInstallerlayout is a layout that represents aGridLayoutlayout configuration for a component, which consists of the number of rows, number of columns, horizontal gap and vertical gap.static final classTheLayout.Nonelayout is a layout that represents the absence of aLayoutManagerfor a component.static final classTheLayout.Unspecificlayout is a layout that represents the lack of a specific layout being set for a component. -
Method Summary
Modifier and TypeMethodDescriptionstatic Layoutborder()A factory method for creating a layout that installs theBorderLayoutonto a component based on the supplied parameters.static Layoutborder(int horizontalGap, int verticalGap) A factory method for creating a layout that installs theBorderLayoutonto a component based on the supplied parameters.static Layoutbox()static Layoutbooleanstatic Layoutflow()Creates a layout that installs theFlowLayoutwith a default alignment ofUI.HorizontalAlignment.CENTERand a default gap of 5 pixels.static Layoutflow(UI.HorizontalAlignment align) A factory method for creating a layout that installs theFlowLayoutonto a component based on the supplied parameters.static Layoutflow(UI.HorizontalAlignment align, int hgap, int vgap) A factory method for creating a layout that installs theFlowLayoutonto a component based on the supplied parameters.static Layoutgrid(int rows, int cols) A factory method for creating a layout that installs theGridLayoutonto a component based on the supplied parameters.static Layoutgrid(int rows, int cols, int horizontalGap, int verticalGap) A factory method for creating a layout that installs theGridLayoutonto a component based on the supplied parameters.inthashCode()voidinstallFor(JComponent component) Installs this layout for the supplied component.static LayoutA factory method for creating a layout that installs theMigLayoutmanager onto a component based on the supplied parameters.static LayoutA factory method for creating a layout that installs theMigLayoutmanager onto a component based on the supplied parameters.static LayoutThis leads to the installation of theMigLayoutlayout manager, which is a powerful general purpose layout manager for Swing.static Layoutnone()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 LayoutA 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 theMigLayoutlayout manager, which is a powerful general purpose layout manager for Swing. Click here for more information.- Parameters:
constr- The layout constraints for the layout.colConstr- The column 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 theMigLayoutmanager 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 theMigLayoutmanager 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 theFlowLayoutonto 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
FlowLayoutonto a component.
-
flow
A factory method for creating a layout that installs theFlowLayoutonto 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
FlowLayoutonto a component.
-
flow
Creates a layout that installs theFlowLayoutwith a default alignment ofUI.HorizontalAlignment.CENTERand a default gap of 5 pixels.- Returns:
- A layout that installs the
FlowLayoutonto a component.
-
border
A factory method for creating a layout that installs theBorderLayoutonto 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
BorderLayoutonto a component.
-
border
A factory method for creating a layout that installs theBorderLayoutonto a component based on the supplied parameters. The installed layout will have a default gap of 0 pixels.- Returns:
- A layout that installs the
BorderLayoutonto a component.
-
grid
A factory method for creating a layout that installs theGridLayoutonto 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
GridLayoutonto a component.
-
grid
A factory method for creating a layout that installs theGridLayoutonto 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
GridLayoutonto a component.
-
box
A factory method for creating a layout that installs theBoxLayoutonto a component based on the suppliedUI.Axisparameter. 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
BoxLayoutonto a component.
-
box
A factory method for creating a layout that installs theBoxLayoutonto a component with a default axis ofUI.Axis.X.- Returns:
- A layout that installs the default
BoxLayoutonto a component.
-