MDateSelector

mseries.utils
Class MultiFormLayout

java.lang.Object
  extended by mseries.utils.VFlowLayout
      extended by mseries.utils.MultiFormLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2, Serializable

public class MultiFormLayout
extends VFlowLayout
implements Serializable

A layout manager that is aware of the type children that have been added to it. If the children are containers that have mseries.utils.FormLayout this layout manager will try to ensure that each column remains vertically aligned with the others giving the effect of continuous vertical columns. Importantly the effect is retained when the container is resized. See the image, notice the field labels have been truncated as the container has been shrunk. The children have borders labelled TopPanel & BottomPanel, both children are containers with FormLayout. In other words each column in one child will have the same width as the corresponding column in the other child components.

Usage:

       JPanel p = new JPanel();
       p.setLayout(new MultiFormLayout());
       p.add(panel1);
       p.add(panel2);

where panel1 and panel2 are JPanels that have a FormLayout. Since the MulitFormLayout gathers the charateristics of each of its child panels as they are added to the containers, they must be complete before they are added, i.e. the application must have first added all the components to each FormLayout container before the FormLayout container is added to the MulitFormLayout container.

There will be occasions when some child components should not participate in the scheme described above. This will occur when the components layout manager is not FormLayout or, if it is FormLayout, when the component is added with the NONPARTICIPANT constraint.

See Also:
FormLayout, Serialized Form

Field Summary
static Integer NONPARTICIPANT
          Pass this constant as a constraint when adding a FormLayout container to the MultiFormLayout container if the FormLayout container is not to participate with other FormLayouts in the MulitFormLayout.
static Integer PARTICIPANT
          Pass this constant as a constraint when adding a FormLayout container to the MultiFormLayout container if the FormLayout container is to participate with other FormLayouts in the MulitFormLayout.
 
Constructor Summary
MultiFormLayout()
          The preferred constructor
MultiFormLayout(Container target)
          This constructor simply delegates to MultiFormLayout(), it remains for backward compatibility with previous versions
 
Method Summary
 void addLayoutComponent(Component comp)
          Not used by this component
 void addLayoutComponent(Component comp, Object constraints)
          Add the components to the layout manager, the container will call this method, not the application code.
 void layoutContainer(Container parent)
          Allow the BoxLayout to lay out the container as usual
 
Methods inherited from class mseries.utils.VFlowLayout
addLayoutComponent, calculateLayoutSize, getLayoutAlignmentX, getLayoutAlignmentY, getLayoutSize, invalidateLayout, maximumLayoutSize, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONPARTICIPANT

public static final Integer NONPARTICIPANT
Pass this constant as a constraint when adding a FormLayout container to the MultiFormLayout container if the FormLayout container is not to participate with other FormLayouts in the MulitFormLayout.


PARTICIPANT

public static final Integer PARTICIPANT
Pass this constant as a constraint when adding a FormLayout container to the MultiFormLayout container if the FormLayout container is to participate with other FormLayouts in the MulitFormLayout. This is the default if no constraints are passed when adding components to the container.

Constructor Detail

MultiFormLayout

public MultiFormLayout(Container target)
This constructor simply delegates to MultiFormLayout(), it remains for backward compatibility with previous versions

Parameters:
target - the thing being layed out (not used)

MultiFormLayout

public MultiFormLayout()
The preferred constructor

Method Detail

addLayoutComponent

public void addLayoutComponent(Component comp)
Not used by this component

Throws:
a - runtime exception if it gets called.

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constraints)
Add the components to the layout manager, the container will call this method, not the application code. In it we measure the width of each column, providing the component is a Container with a FormLayout, and add some struts to each component representing the preferred widths of the columns. The largest preferred width of each column is used. The FormLayouts themselves actually manage the widths of their columns but the struts that are added ensure that their calculations yield the same values giving the same column widths when the container is resized.

Specified by:
addLayoutComponent in interface LayoutManager2
Overrides:
addLayoutComponent in class VFlowLayout

layoutContainer

public void layoutContainer(Container parent)
Allow the BoxLayout to lay out the container as usual

Specified by:
layoutContainer in interface LayoutManager
Overrides:
layoutContainer in class VFlowLayout

MDateSelector

Copyright © 2001-2007 M Newstead. All Rights Reserved.