private Dimension calcSizeWithRestriction(int width, Container target) { int h = 0; for (Component c : target.getComponents()) { ((PgmPanel) c).setWidth(width); h += c.getPreferredSize().height + SEPARATOR_THICKNESS; } return new Dimension(width, h); }
public void layoutContainer(Container target) { Insets insets = target.getInsets(); int width = (_width > 0 ? _width : target.getWidth()) - insets.left - insets.right; int height = target.getHeight() - insets.top - insets.bottom; int x = insets.left; int y = insets.top; PgmPanel[] ps = Arrays.copyOf(target.getComponents(), target.getComponentCount(), PgmPanel[].class); _descComparator.setOriginDate(System.currentTimeMillis()); Arrays.sort(ps, _descComparator); for (PgmPanel p : ps) { p.setWidth(width); int h = p.getPreferredSize().height; p.setBounds(x, y, width, h); y += h + SEPARATOR_THICKNESS; } }