Class StackLayout
- java.lang.Object
-
- org.jdesktop.swingx.StackLayout
-
- All Implemented Interfaces:
java.awt.LayoutManager
,java.awt.LayoutManager2
public class StackLayout extends java.lang.Object implements java.awt.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 toCardLayout
, 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 bootom:
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
-
-
Constructor Summary
Constructors Constructor Description StackLayout()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
void
addLayoutComponent(java.lang.String name, java.awt.Component comp)
float
getLayoutAlignmentX(java.awt.Container target)
float
getLayoutAlignmentY(java.awt.Container target)
void
invalidateLayout(java.awt.Container target)
void
layoutContainer(java.awt.Container parent)
java.awt.Dimension
maximumLayoutSize(java.awt.Container target)
java.awt.Dimension
minimumLayoutSize(java.awt.Container parent)
java.awt.Dimension
preferredLayoutSize(java.awt.Container parent)
void
removeLayoutComponent(java.awt.Component comp)
-
-
-
Field Detail
-
BOTTOM
public static final java.lang.String BOTTOM
Use this constraint to add a component at the bottom of the stack.- See Also:
- Constant Field Values
-
TOP
public static final java.lang.String TOP
Use this contrainst to add a component at the top of the stack.- See Also:
- Constant Field Values
-
-
Method Detail
-
addLayoutComponent
public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
- Specified by:
addLayoutComponent
in interfacejava.awt.LayoutManager2
-
addLayoutComponent
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
- Specified by:
addLayoutComponent
in interfacejava.awt.LayoutManager
-
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component comp)
- Specified by:
removeLayoutComponent
in interfacejava.awt.LayoutManager
-
getLayoutAlignmentX
public float getLayoutAlignmentX(java.awt.Container target)
- Specified by:
getLayoutAlignmentX
in interfacejava.awt.LayoutManager2
-
getLayoutAlignmentY
public float getLayoutAlignmentY(java.awt.Container target)
- Specified by:
getLayoutAlignmentY
in interfacejava.awt.LayoutManager2
-
invalidateLayout
public void invalidateLayout(java.awt.Container target)
- Specified by:
invalidateLayout
in interfacejava.awt.LayoutManager2
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
- Specified by:
preferredLayoutSize
in interfacejava.awt.LayoutManager
-
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
- Specified by:
minimumLayoutSize
in interfacejava.awt.LayoutManager
-
maximumLayoutSize
public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
- Specified by:
maximumLayoutSize
in interfacejava.awt.LayoutManager2
-
layoutContainer
public void layoutContainer(java.awt.Container parent)
- Specified by:
layoutContainer
in interfacejava.awt.LayoutManager
-
-