Class LambdaLayout

  extended by
      extended by
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2,

public class LambdaLayout
extends KappaLayout
implements java.awt.LayoutManager2,

LambdaLayout, a Java layout manager.
Copyright (C) 2001, Dale Anson

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

LambdaLayout -- based on KappaLayout, but handles stretching of components differently. From e-mail I've received about KappaLayout, many people are expecting a different stretching behavior when resizing a Frame. LambdaLayout has this expected behaviour, in that components with the 's' constraint set to 'w', 'h', or 'wh'/'hw' will resize as the frame resizes. Like KappaLayout, LambdaLayout respects the preferred size of components and will not shrink a component to less than it's preferred size.
Example use:
This will put a button on a panel in the top of its cell, stretched to fill the cell width, with a 3 pixel pad:
Panel p = new Panel(new LambdaLayout()); Button b = new Button("OK"); p.add(b, "0, 0, 1, 2, 2, w, 3");
The constraints string has this layout:
"x, y, w, h, a, s, p"
defined as follows:

Parameters may be omitted (default values will be used), e.g., p.add(new Button("OK), "1,4,,,w,");
which means put the button at column 1, row 4, default 1 column wide, default 1 row tall, stretch to fit width of column, no padding.
Spaces in the parameter string are ignored, so these are identical:
p.add(new Button("OK), "1,4,,,w,");
p.add(new Button("OK), " 1, 4, , , w");

Rather than use a constraints string, a Constraints object may be used directly, similar to how GridBag uses a GridBagConstraint. E.g,
Panel p = new Panel();
LambdaLayout tl = new LambdaLayout();
LambdaLayout.Constraints con = tl.getConstraint();
con.x = 1;
con.y = 2;
con.w = 2;
con.h = 2;
con.s = "wh";
panel.add(new Button("OK"), con);
con.x = 3;
panel.add(new Button("Cancel"), con);

Note that the same Constraints can be reused, thereby reducing the number of objects created.

Dale Anson
See Also:
Serialized Form

Nested Class Summary
Nested classes/interfaces inherited from class
KappaLayout.Constraints, KappaLayout.Strut
Field Summary
Fields inherited from class
_0dim, _col_count, _col_widths, _components, _constraints, _preferred_height, _preferred_width, _row_count, _row_heights, _same_height_rows, _same_width_cols, _size_unknown, _stretch, _table, E, N, NE, NW, R, S, SE, SW, W
Constructor Summary
Method Summary
 void layoutContainer(java.awt.Container parent)
          Required by LayoutManager, does all the real layout work.
Methods inherited from class
addLayoutComponent, addLayoutComponent, calculateDimensions, createConstraint, createHorizontalStrut, createHorizontalStrut, createStrut, createStrut, createVerticalStrut, createVerticalStrut, getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, makeColumnsSameWidth, makeColumnsSameWidth, makeColumnsSameWidth, makeRowsSameHeight, makeRowsSameHeight, makeRowsSameHeight, maximumLayoutSize, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent, setColumnWidth, setRowHeight, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.LayoutManager2
addLayoutComponent, getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, maximumLayoutSize
Methods inherited from interface java.awt.LayoutManager
addLayoutComponent, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent

Constructor Detail


public LambdaLayout()
Method Detail


public void layoutContainer(java.awt.Container parent)
Required by LayoutManager, does all the real layout work. This is the only method in LambdaLayout, all other methods are in KappaLayout.

Specified by:
layoutContainer in interface java.awt.LayoutManager
layoutContainer in class KappaLayout

Copyright © 2000 Dale Anson, All Rights Reserved.
KappaLayout Home Page