in jflex/src/main/java/jflex/gui/GridPanel.java [57:117]
public void doLayout() {
Dimension size = getSize();
size.height -= insets.top + insets.bottom;
size.width -= insets.left + insets.right;
float cellWidth = size.width / cols;
float cellHeight = size.height / rows;
for (int i = 0; i < constraints.size(); i++) {
GridPanelConstraint c = constraints.get(i);
float x = cellWidth * c.x + insets.left + hgap / 2;
float y = cellHeight * c.y + insets.right + vgap / 2;
float width, height;
if (c.handle == Handles.FILL) {
width = (cellWidth - hgap) * c.width;
height = (cellHeight - vgap) * c.height;
} else {
Dimension d = c.component.getPreferredSize();
width = d.width;
height = d.height;
}
switch (c.handle) {
case Handles.TOP_CENTER:
x += (cellWidth + width) / 2;
break;
case Handles.TOP_RIGHT:
x += cellWidth - width;
break;
case Handles.CENTER_LEFT:
y += (cellHeight + height) / 2;
break;
case Handles.CENTER:
x += (cellWidth + width) / 2;
y += (cellHeight + height) / 2;
break;
case Handles.CENTER_RIGHT:
y += (cellHeight + height) / 2;
x += cellWidth - width;
break;
case Handles.BOTTOM:
y += cellHeight - height;
break;
case Handles.BOTTOM_CENTER:
x += (cellWidth + width) / 2;
y += cellHeight - height;
break;
case Handles.BOTTOM_RIGHT:
y += cellHeight - height;
x += cellWidth - width;
break;
default:
// do nothing
}
c.component.setBounds(new Rectangle((int) x, (int) y, (int) width, (int) height));
}
}