public class LambdaLayout extends KappaLayout implements java.awt.LayoutManager2, java.io.Serializable
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:
By popular request, the alignment constraint can also be represented as:
NW N NE
W 0 E
SW S SE
which are compass directions for alignment within the cell.
p.add(new Button("OK), "1,4,,,w,");
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();
p.setLayout(tl);
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.
KappaLayout.Constraints, KappaLayout.Strut
_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 and Description |
---|
LambdaLayout() |
Modifier and Type | Method and Description |
---|---|
void |
layoutContainer(java.awt.Container parent)
Required by LayoutManager, does all the real layout work.
|
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public void layoutContainer(java.awt.Container parent)
layoutContainer
in interface java.awt.LayoutManager
layoutContainer
in class KappaLayout