public class StackLayout extends Object implements 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.
Modifier and Type | Field and Description |
---|---|
static String |
BOTTOM
Use this constraint to add a component at the bottom of the stack.
|
private List<Component> |
components |
static String |
TOP
Use this contrainst to add a component at the top of the stack.
|
Constructor and Description |
---|
StackLayout() |
Modifier and Type | Method and Description |
---|---|
void |
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) |
Dimension |
maximumLayoutSize(Container target) |
Dimension |
minimumLayoutSize(Container parent) |
Dimension |
preferredLayoutSize(Container parent) |
void |
removeLayoutComponent(Component comp) |
public static final String BOTTOM
public static final String TOP
private List<Component> components
public StackLayout()
public void addLayoutComponent(Component comp, Object constraints)
addLayoutComponent
in interface LayoutManager2
public void addLayoutComponent(String name, Component comp)
addLayoutComponent
in interface LayoutManager
public void removeLayoutComponent(Component comp)
removeLayoutComponent
in interface LayoutManager
public float getLayoutAlignmentX(Container target)
getLayoutAlignmentX
in interface LayoutManager2
public float getLayoutAlignmentY(Container target)
getLayoutAlignmentY
in interface LayoutManager2
public void invalidateLayout(Container target)
invalidateLayout
in interface LayoutManager2
public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize
in interface LayoutManager
public Dimension minimumLayoutSize(Container parent)
minimumLayoutSize
in interface LayoutManager
public Dimension maximumLayoutSize(Container target)
maximumLayoutSize
in interface LayoutManager2
public void layoutContainer(Container parent)
layoutContainer
in interface LayoutManager
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses