Methods Summary |
---|
public void | addLayoutComponent(java.lang.String constraint, java.awt.Component comp)
|
public void | addLayoutComponent(java.awt.Component comp, java.lang.Object constraint)
|
public float | getLayoutAlignmentX(java.awt.Container parent) return 0.5f;
|
public float | getLayoutAlignmentY(java.awt.Container parent) return 0.5f;
|
public void | invalidateLayout(java.awt.Container parent)
|
public void | layoutContainer(java.awt.Container parent)The method that actually performs the layout.
Called by the Container
Insets insets = parent.getInsets();
Dimension parent_size = parent.getSize();
Component kid;
int nkids = parent.getComponentCount();
int x0 = insets.left + margin_width; // The base X position
int x;
int y = insets.top + margin_height; // Start at the top of the column
for(int i = 0; i < nkids; i++) { // Loop through the kids
kid = parent.getComponent(i); // Get the kid
if (!kid.isVisible()) continue; // Skip hidden ones
Dimension pref = kid.getPreferredSize(); // How big is it?
switch(alignment) { // Compute X coordinate
default:
case LEFT: x = x0; break;
case CENTER: x = (parent_size.width - pref.width)/2; break;
case RIGHT:
x = parent_size.width-insets.right-margin_width-pref.width;
break;
}
// Set the size and position of this kid
kid.setBounds(x, y, pref.width, pref.height);
y += pref.height + spacing; // Get Y position of the next one
}
|
protected java.awt.Dimension | layoutSize(java.awt.Container parent, int sizetype)
int nkids = parent.getComponentCount();
Dimension size = new Dimension(0,0);
Insets insets = parent.getInsets();
int num_visible_kids = 0;
// Compute maximum width and total height of all visible kids
for(int i = 0; i < nkids; i++) {
Component kid = parent.getComponent(i);
Dimension d;
if (!kid.isVisible()) continue;
num_visible_kids++;
if (sizetype == 1) d = kid.getPreferredSize();
else if (sizetype == 2) d = kid.getMinimumSize();
else d = kid.getMaximumSize();
if (d.width > size.width) size.width = d.width;
size.height += d.height;
}
// Now add in margins and stuff
size.width += insets.left + insets.right + 2*margin_width;
size.height += insets.top + insets.bottom + 2*margin_height;
if (num_visible_kids > 1)
size.height += (num_visible_kids - 1) * spacing;
return size;
|
public java.awt.Dimension | maximumLayoutSize(java.awt.Container parent)The Container calls this to find out how big the layout can be
return layoutSize(parent, 3);
|
public java.awt.Dimension | minimumLayoutSize(java.awt.Container parent)The Container calls this to find out how big the layout must be
return layoutSize(parent, 2);
|
public java.awt.Dimension | preferredLayoutSize(java.awt.Container parent)The Container calls this to find out how big the layout should to be
return layoutSize(parent, 1);
|
public void | removeLayoutComponent(java.awt.Component comp)
|