Methods Summary |
---|
public void | addLayoutComponent(java.lang.String name, java.awt.Component comp)
|
public void | layoutContainer(java.awt.Container parent)
Insets insets = parent.insets();
int maxWidth = parent.size().width
- (insets.left + insets.right);
int maxHeight = parent.size().height
- (insets.top + insets.bottom);
int nComps = parent.countComponents();
// Go through the components' sizes, if neither preferredLayoutSize()
// nor minimumLayoutSize() has been called.
if (sizeUnknown) {
setSizes(parent);
}
int previousWidth = 0, previousHeight = 0;
int x = 0, y = insets.top + gap/2;
int rowh = 0, start = 0;
int yFudge = 0;
boolean oneColumn = false;
// Go through the components' sizes, if neither preferredLayoutSize()
// nor minimumLayoutSize() has been called.
if (sizeUnknown) {
setSizes(parent);
}
if (maxHeight > preferredHeight) {
yFudge = (maxHeight - preferredHeight)/(nComps);
}
for (int i = 0 ; i < nComps ; i++) {
Component c = parent.getComponent(i);
if (c.isVisible()) {
Dimension d = c.preferredSize();
if (i!=0)
y+=(previousHeight + yFudge + gap);
else
y+=(previousHeight + (yFudge + gap)/2 );
// Set the component's size and position.
c.reshape(0, y, maxWidth, d.height);
previousWidth = d.width;
previousHeight = d.height;
}
}
|
public java.awt.Dimension | minimumLayoutSize(java.awt.Container parent)
Dimension dim = new Dimension(0, 0);
int nComps = parent.countComponents();
setSizes(parent);
//Always add the container's insets!
Insets insets = parent.insets();
dim.width = minWidth + insets.left + insets.right;
dim.height = minHeight + insets.top + insets.bottom;
sizeUnknown = false;
return dim;
|
public java.awt.Dimension | preferredLayoutSize(java.awt.Container parent)
Dimension dim = new Dimension(0, 0);
int nComps = parent.countComponents();
setSizes(parent);
//Always add the container's insets!
Insets insets = parent.insets();
dim.width = preferredWidth + insets.left + insets.right;
dim.height = preferredHeight + insets.top + insets.bottom;
sizeUnknown = false;
return dim;
|
public void | removeLayoutComponent(java.awt.Component comp)
|
private void | setSizes(java.awt.Container parent)calculates minimum size and preffered size
int nComps = parent.countComponents();
Dimension d = null;
//Reset preferred/minimum width and height.
preferredWidth = 0;
preferredHeight = 0;
minWidth = 0;
minHeight = 0;
for (int i = 0; i < nComps; i++) {
Component c = parent.getComponent(i);
if (c.isVisible()) {
d = c.preferredSize();
minWidth = Math.max(c.minimumSize().width, minWidth);
preferredWidth = Math.max(c.preferredSize().width, preferredWidth);
minHeight += (c.minimumSize().height + gap);
preferredHeight += (c.preferredSize().height + gap);
}
}
|
public java.lang.String | toString()
return getClass().getName() + "[gap=" + gap +"]";
|