All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.wizards.awt.HeaderLayout

java.lang.Object
   |
   +----com.sun.wizards.awt.HeaderLayout

public class HeaderLayout
extends Object
implements LayoutManager, LayoutManager2, Serializable
HeaderLayout is a layout manager that positions objects according to the spacing of objects in a separate panel. That is, the HeaderLayout uses a separate panel as a template to position its own objects.

The objects controlled by the HeaderLayout can be positioned relative to the objects within the template. They can be left justified, right justified, or centered.

Graphic of HeaderLayout centering buttons from a template.

Here is the code for this applet:


 import java.applet.Applet;
 import java.awt.*;
 import com.sun.wizards.awt.*;
 public class Test extends Applet
 {
   public void init()
     {
       setLayout(new BorderLayout());
       Panel template = new Panel(new BiflowLayout());
       template.add(new Label("Column 1"), "Left");
       template.add(new Label("Column 2"), "Right");
       template.add(new Label("Column 3"), "Right");
       add(template, "North");
       HeaderLayout headerLayout = new HeaderLayout(template,
 						   new int[] {HeaderLayout.CENTER,
 								HeaderLayout.CENTER,
        							HeaderLayout.CENTER},
 						   0, 0);
       Panel panel = new Panel(headerLayout);
       panel.add(new Checkbox("one", null, true));
       panel.add(new Checkbox("two", null, true));
       panel.add(new Checkbox("three", null, true));
       add(panel, "South");
     }
 }
 


Variable Index

 o CENTER
A tag used for centering objects to corresponding objects in the header panel.
 o LEFT
A tag used for aligning the left side of the objects to the objects in the header panel.
 o RIGHT
A tag used for aligning the right side of the objects to the objects in the header panel.

Constructor Index

 o HeaderLayout(Container)
Creates a new layout manager that will lay out objects according to the spacing of objects in the specified panel.
 o HeaderLayout(Container, int[], int, int)
Creates a new layout manager that will lay out objects according to the spacing of objects in the specified panel.

Method Index

 o addLayoutComponent(Component, Object)
Adds the specified component to the layout, using the specified constraint object.
 o addLayoutComponent(String, Component)
Adds the specified component with the specified name to the layout.
 o getLayoutAlignmentX(Container)
Returns the alignment along the x axis.
 o getLayoutAlignmentY(Container)
Returns the alignment along the y axis.
 o invalidateLayout(Container)
Invalidates the layout, indicating that if the layout manager has cached information, it should be discarded.
 o layoutContainer(Container)
Lays out the container in the specified panel.
 o maximumLayoutSize(Container)
Returns the maximum size of this component.
 o minimumLayoutSize(Container)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
 o preferredLayoutSize(Container)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
 o removeLayoutComponent(Component)
Removes the specified component from the layout.

Variables

 o LEFT
 public static final int LEFT
A tag used for aligning the left side of the objects to the objects in the header panel.

 o CENTER
 public static final int CENTER
A tag used for centering objects to corresponding objects in the header panel.

 o RIGHT
 public static final int RIGHT
A tag used for aligning the right side of the objects to the objects in the header panel.

Constructors

 o HeaderLayout
 public HeaderLayout(Container header)
Creates a new layout manager that will lay out objects according to the spacing of objects in the specified panel.

Parameters:
header - The panel of spaced objects that this layout manager will align its objects to.
 o HeaderLayout
 public HeaderLayout(Container header,
                     int alignment[],
                     int hgap,
                     int vgap)
Creates a new layout manager that will lay out objects according to the spacing of objects in the specified panel. The layout will align objects according to the values in the specified alignment array. Objects will be laid out with the specified horizontal and vertical gaps.

Parameters:
header - The panel of spaced objects that this layout manager will align its objects to.
alignment - The desired alignment of each object.
hgap - The horizontal gap between components.
vgap - The vertical gap between components.

Methods

 o addLayoutComponent
 public void addLayoutComponent(String name,
                                Component comp)
Adds the specified component with the specified name to the layout.

Parameters:
name - The component name.
comp - The component to be added.
 o addLayoutComponent
 public void addLayoutComponent(Component comp,
                                Object constraints)
Adds the specified component to the layout, using the specified constraint object. The HeaderLayout ignores the constraint object.

Parameters:
comp - The component to be added.
constraints - Not used.
 o removeLayoutComponent
 public void removeLayoutComponent(Component comp)
Removes the specified component from the layout.

Parameters:
comp - The component to be removed.
 o minimumLayoutSize
 public Dimension minimumLayoutSize(Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.

Parameters:
parent - The component to be laid out.
Returns:
The minimum size.
 o preferredLayoutSize
 public Dimension preferredLayoutSize(Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.

Parameters:
parent - The component to be laid out.
Returns:
The preferred size.
 o layoutContainer
 public void layoutContainer(Container parent)
Lays out the container in the specified panel.

Parameters:
parent - The component which needs to be laid out.
 o maximumLayoutSize
 public Dimension maximumLayoutSize(Container target)
Returns the maximum size of this component.

Parameters:
parent - The component to be laid out.
Returns:
The maximum size.
 o getLayoutAlignmentX
 public float getLayoutAlignmentX(Container parent)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Parameters:
parent - The component that needs to be laid out.
 o getLayoutAlignmentY
 public float getLayoutAlignmentY(Container parent)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Parameters:
parent - The component that needs to be laid out.
 o invalidateLayout
 public void invalidateLayout(Container target)
Invalidates the layout, indicating that if the layout manager has cached information, it should be discarded.

Parameters:
parent - The component to be invalidated.

All Packages  Class Hierarchy  This Package  Previous  Next  Index