void (@NotNull Dimension size2Fit, @NotNull List<Rectangle> bounds) { bounds.clear(); for (int i = 0; i < getComponentCount(); i++) { bounds.add(new Rectangle()); } if (myLayoutPolicy == NOWRAP_LAYOUT_POLICY) { calculateBoundsNowrapImpl(bounds); } else if (myLayoutPolicy == WRAP_LAYOUT_POLICY) { calculateBoundsWrapImpl(size2Fit, bounds); } else if (myLayoutPolicy == AUTO_LAYOUT_POLICY) { calculateBoundsAutoImp(size2Fit, bounds); } else { throw new IllegalStateException("unknown layoutPolicy: " + myLayoutPolicy); } if (getComponentCount() > 0 && size2Fit.width < Integer.MAX_VALUE) { Insets insets = getInsets(); int rightOffset = insets.right; for (int i = getComponentCount() - 1, j = 1; i > 0; i--, j++) { final Component component = getComponent(i); if (component instanceof JComponent && ((JComponent)component).getClientProperty(RIGHT_ALIGN_KEY) == Boolean.TRUE) { rightOffset += bounds.get(i).width; Rectangle r = bounds.get(bounds.size() - j); r.x = size2Fit.width - rightOffset; } } } }