MDateSelector

mseries.utils
Class FormCellLayout

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

public class FormCellLayout
extends FormLayout

A layout manager that lays out a container in one, horizonatal row. The resizing and placement policies are inherited from FormLayout. Components are added to their container using FormConstraints and this layout manager then ignores many of the values !. The intention is that it is easy for the application programmer to use this layout manager, it does not allow anything that could not be achieved with careful use of FormLayout. It is designed to be used to manage a small group of components that should ideally be placed in the same cell in a FormLayout. The image below shows a FormLayout with superimposed grid lines, the cell (1,1) contains 3 components, two JTextFields and a JLabel.

This cell contains a JPanel that has a FormCellLayout, the FormLayout automatically calculates the insets for its child components, the left most component gets zero left insets, the right most one zero right insets, all components get zero top and bottom insets. These values can not be over ridden by the application program so the FormCellLayout may not be the most appropriate Layout Manager to use outside of a FormLayout. (Remember the cell itself has insets)

As components are added to the container, their x coordinate is automatically calculated, the first component to be added gets gridx=0, the next 1 etc. The gridy value is always zero as this layout manager can deal with only one row.

The following code shows the usage of the FormCellLayout to produce the effects shown in the sample image above:


            public JPanel makeUOMPanel()
            {
                JPanel p = new JPanel();
                p.setLayout(new FormCellLayout());

                FormConstraints c =new FormConstraints();

                JTextField t1= new JTextField(5);
                c.anchor=FormConstraints.WEST;
                p.add(t1, c);

                c.anchor=FormConstraints.EAST;
                JLabel l2=new JLabel("Printer");
                p.add(l2, c);

                JTextField t2= new JTextField(5);
                c.anchor=FormConstraints.WEST;
                p.add(t2, c);

                return p;
            }
The complete panel is added to the FormLayout with the following lines of code
            JPanel ip=makeUOMPanel();

            c.gridx=FormConstraints.RELATIVE;
            c.anchor=FormConstraints.WEST;
            c.spansColumns=true;
            p.add(ip, c);

See Also:
FormLayout, Serialized Form

Field Summary
 
Fields inherited from class mseries.utils.FormLayout
comptable, defaultConstraints, info, MAXGRIDSIZE, MINHEIGHT, MINWIDTH
 
Constructor Summary
FormCellLayout()
           
 
Method Summary
 void addLayoutComponent(Component comp, Object constraints)
          Adds the specified component to the layout, using the specified constraint object.
 void layoutContainer(Container parent)
          Lays out the specified container using this form layout.
protected  void resetConstraints()
           
 
Methods inherited from class mseries.utils.FormLayout
addLayoutComponent, applyGravity, calculateGridSize, getConstraints, getInfo, getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, lookupConstraints, maximumLayoutSize, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent, setComponentBounds, setConstraints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormCellLayout

public FormCellLayout()
Method Detail

layoutContainer

public void layoutContainer(Container parent)
Lays out the specified container using this form layout. This method reshapes components in the specified container in order to satisfy the contraints of this FormLayout object.

Most applications do not call this method directly.

Specified by:
layoutContainer in interface LayoutManager
Overrides:
layoutContainer in class FormLayout
Parameters:
parent - the container in which to do the layout.
See Also:
Container, Container.doLayout()

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constraints)
Adds the specified component to the layout, using the specified constraint object.

Specified by:
addLayoutComponent in interface LayoutManager2
Overrides:
addLayoutComponent in class FormLayout
Parameters:
comp - the component to be added.
constraints - an object that determines how the component is added to the layout.

resetConstraints

protected void resetConstraints()

MDateSelector

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