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.LayoutManager2StackLayoutis 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 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.
StackLayoutworks only with JSE 1.5 and Java SE 6 and greater.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBOTTOMUse this constraint to add a component at the bottom of the stack.private java.util.List<java.awt.Component>componentsstatic java.lang.StringTOPUse this contrainst to add a component at the top of the stack.
-
Constructor Summary
Constructors Constructor Description StackLayout()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLayoutComponent(java.awt.Component comp, java.lang.Object constraints)voidaddLayoutComponent(java.lang.String name, java.awt.Component comp)floatgetLayoutAlignmentX(java.awt.Container target)floatgetLayoutAlignmentY(java.awt.Container target)voidinvalidateLayout(java.awt.Container target)voidlayoutContainer(java.awt.Container parent)java.awt.DimensionmaximumLayoutSize(java.awt.Container target)java.awt.DimensionminimumLayoutSize(java.awt.Container parent)java.awt.DimensionpreferredLayoutSize(java.awt.Container parent)voidremoveLayoutComponent(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
-
components
private java.util.List<java.awt.Component> components
-
-
Method Detail
-
addLayoutComponent
public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)- Specified by:
addLayoutComponentin interfacejava.awt.LayoutManager2
-
addLayoutComponent
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)- Specified by:
addLayoutComponentin interfacejava.awt.LayoutManager
-
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component comp)
- Specified by:
removeLayoutComponentin interfacejava.awt.LayoutManager
-
getLayoutAlignmentX
public float getLayoutAlignmentX(java.awt.Container target)
- Specified by:
getLayoutAlignmentXin interfacejava.awt.LayoutManager2
-
getLayoutAlignmentY
public float getLayoutAlignmentY(java.awt.Container target)
- Specified by:
getLayoutAlignmentYin interfacejava.awt.LayoutManager2
-
invalidateLayout
public void invalidateLayout(java.awt.Container target)
- Specified by:
invalidateLayoutin interfacejava.awt.LayoutManager2
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
- Specified by:
preferredLayoutSizein interfacejava.awt.LayoutManager
-
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
- Specified by:
minimumLayoutSizein interfacejava.awt.LayoutManager
-
maximumLayoutSize
public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
- Specified by:
maximumLayoutSizein interfacejava.awt.LayoutManager2
-
layoutContainer
public void layoutContainer(java.awt.Container parent)
- Specified by:
layoutContainerin interfacejava.awt.LayoutManager
-
-