net.sf.zig_project.gpl.common.gfx
Class FormLayout
java.lang.Object
net.sf.zig_project.gpl.common.gfx.FormLayout
- All Implemented Interfaces:
- LayoutManager, LayoutManager2
- public class FormLayout
- extends Object
- implements LayoutManager2
A very simple to use LayoutManager, well suited for Forms. This class has only been
minimally tested, so Use at your own risk! It is however, very simple,
providing a much easier way of laying out components than GridBagLayout, and is
also much faster about responding to layout changes. I was intending to replace this
with another counterpart, but this will be some time off. In the mean time,
enhancements and documentation for this class are of a very low priority.
Useage: very easy. Forms are broken into labels and fields. Labels are positioned
to the left or above their corresponding field components, and are only given as
much space as they require. Fields are placed either to the right or just below a
label, and are stretched to fill any unoccupied space. Entries are created by first
adding a label, then adding a field. (Fields may be added without a label or
vise-versa, but this can get confusing). For example:
public class Sample1 {
public static void main(String[] args) {
Frame f=new Frame("Example Form");
f.setLayout(new FormLayout());
f.add(new Label("Field 1", Label.RIGHT), FormLayout.LEFT);
f.add(new TextField("Example text"), FormLayout.RIGHT);
f.add(new Label("2", Label.RIGHT), FormLayout.LEFT);
f.add(new TextField("Somewhat longer example of text"), FormLayout.RIGHT);
f.add(new Label("Comments", Label.CENTER), FormLayout.TOP);
f.add(new TextArea("FormLayout\nis really\nCOOL!"), FormLayout.BOTTOM);
new WindowHandler().APCS(f);}
}
The first two labels share the same column width, and excess frame space is given to
their fields on the right. The last label is given the width of the frame, and it's
field is given any excess height.
If multiple TOP / BOTTOM elements are added, the excess height is split evenly among
the BOTTOM elements.
- Version:
- October 5, 2004
- Author:
- Frank Ziglar
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LEFT
public static final String LEFT
- See Also:
- Constant Field Values
RIGHT
public static final String RIGHT
- See Also:
- Constant Field Values
TOP
public static final String TOP
- See Also:
- Constant Field Values
BOTTOM
public static final String BOTTOM
- See Also:
- Constant Field Values
FormLayout
public FormLayout()
FormLayout
public FormLayout(int gut,
int hpad,
int vpad)
getHorizontalEntryPadding
public int getHorizontalEntryPadding()
getVerticalEntryPadding
public int getVerticalEntryPadding()
setHorizonalEntryPadding
public void setHorizonalEntryPadding(int pad)
setVerticalEntryPadding
public void setVerticalEntryPadding(int pad)
setGutterWidth
public void setGutterWidth(int gut)
getGutterWidth
public int getGutterWidth()
addLayoutComponent
public void addLayoutComponent(String name,
Component c)
- Specified by:
addLayoutComponent
in interface LayoutManager
addLayoutComponent
public void addLayoutComponent(Component addme,
Object position)
- Specified by:
addLayoutComponent
in interface LayoutManager2
removeLayoutComponent
public void removeLayoutComponent(Component c)
- Specified by:
removeLayoutComponent
in interface LayoutManager
layoutContainer
public void layoutContainer(Container c)
- Specified by:
layoutContainer
in interface LayoutManager
minimumLayoutSize
public Dimension minimumLayoutSize(Container c)
- Specified by:
minimumLayoutSize
in interface LayoutManager
preferredLayoutSize
public Dimension preferredLayoutSize(Container c)
- Specified by:
preferredLayoutSize
in interface LayoutManager
maximumLayoutSize
public Dimension maximumLayoutSize(Container c)
- Specified by:
maximumLayoutSize
in interface LayoutManager2
getLayoutAlignmentX
public float getLayoutAlignmentX(Container c)
- Specified by:
getLayoutAlignmentX
in interface LayoutManager2
getLayoutAlignmentY
public float getLayoutAlignmentY(Container c)
- Specified by:
getLayoutAlignmentY
in interface LayoutManager2
invalidateLayout
public void invalidateLayout(Container c)
- Specified by:
invalidateLayout
in interface LayoutManager2