Class StackLayout
- All Implemented Interfaces:
LayoutManager
,LayoutManager2
StackLayout
is a Swing layout aimed to act as the layers
stack of most popuplar graphics editing tools like The GIMP or
Photoshop. While similar to CardLayout
, this layout
displays all the components of the container. If you are using non-rectangular
components (i.e. transparent) you will see them from top to bottom of the
stack.
When using this layout, each component can be added in the container either on top of the stack or at the bottom:
JPanel panel = new JPanel(new StackLayout()); panel.add(new JLabel("On top"), StackLayout.TOP); panel.add(new JLabel("At bottom"), StackLayout.BOTTOM);If you don't specify the constraint, the component will be added at the top of the components stack.
All the components managed by this layout will be given the same size as the container itself. The minimum, maximum and preferred size of the container are based upon the largest minimum, maximum and preferred size of the children components.
StackLayout
works only with JSE 1.5 and Java SE 6 and
greater.
- Author:
- Romain Guy romain.guy@mac.com
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLayoutComponent
(Component comp, Object constraints) void
addLayoutComponent
(String name, Component comp) float
getLayoutAlignmentX
(Container target) float
getLayoutAlignmentY
(Container target) void
invalidateLayout
(Container target) void
layoutContainer
(Container parent) maximumLayoutSize
(Container target) minimumLayoutSize
(Container parent) preferredLayoutSize
(Container parent) void
-
Field Details
-
BOTTOM
Use this constraint to add a component at the bottom of the stack.- See Also:
-
TOP
Use this contrainst to add a component at the top of the stack.- See Also:
-
-
Constructor Details
-
StackLayout
public StackLayout()
-
-
Method Details
-
addLayoutComponent
- Specified by:
addLayoutComponent
in interfaceLayoutManager2
-
addLayoutComponent
- Specified by:
addLayoutComponent
in interfaceLayoutManager
-
removeLayoutComponent
- Specified by:
removeLayoutComponent
in interfaceLayoutManager
-
getLayoutAlignmentX
- Specified by:
getLayoutAlignmentX
in interfaceLayoutManager2
-
getLayoutAlignmentY
- Specified by:
getLayoutAlignmentY
in interfaceLayoutManager2
-
invalidateLayout
- Specified by:
invalidateLayout
in interfaceLayoutManager2
-
preferredLayoutSize
- Specified by:
preferredLayoutSize
in interfaceLayoutManager
-
minimumLayoutSize
- Specified by:
minimumLayoutSize
in interfaceLayoutManager
-
maximumLayoutSize
- Specified by:
maximumLayoutSize
in interfaceLayoutManager2
-
layoutContainer
- Specified by:
layoutContainer
in interfaceLayoutManager
-