Component[] components = container_.getComponents();
int hoffset = container_.getInsets().left;
int voffset = container_.getInsets().top;
for (int i = 0; i < components.length; i++) {
Component c = components[ i];
/*
* Get the contained container to lay itself out at its preferred
* size.
*/
if (c instanceof Container) {
Container cont = (Container) c;
cont.setSize(cont.minimumSize());
cont.doLayout();
}
Dimension componentsize = c.getSize();
if (_axis == X_AXIS) {
float alignment = c.getAlignmentY();
if (alignment == Component.TOP_ALIGNMENT)
voffset = container_.getInsets().top;
else if (alignment == Component.CENTER_ALIGNMENT) {
voffset = (containersize.height - componentsize.height) / 2;
} else if (alignment == Component.BOTTOM_ALIGNMENT) {
voffset = containersize.height
- container_.getInsets().bottom
- componentsize.height;
}
c.setLocation(hoffset, voffset);
hoffset += componentsize.width;
} else {
float alignment = c.getAlignmentX();
if (alignment == Component.LEFT_ALIGNMENT)
hoffset = container_.getInsets().left;
else if (alignment == Component.CENTER_ALIGNMENT) {
hoffset = (containersize.width - componentsize.width) / 2;
} else if (alignment == Component.RIGHT_ALIGNMENT) {
hoffset = containersize.width
- container_.getInsets().right
- componentsize.width;
}
c.setLocation(hoffset, voffset);
voffset += componentsize.height;
}
}
}