Dimension (Container container, boolean aligned) { int gap2 = 2 * myGap.get(); synchronized (container.getTreeLock()) { Dimension top = getPreferredSize(myTop); Dimension bottom = getPreferredSize(myBottom); Dimension center = getPreferredSize(myCenter); Dimension result = join(join(join(null, gap2, top), gap2, center), gap2, bottom); if (result == null) { result = new Dimension(); } else if (aligned && center != null) { int topHeight = top == null ? 0 : top.height; int bottomHeight = bottom == null ? 0 : bottom.height; result.height += Math.abs(topHeight - bottomHeight); } JBInsets.addTo(result, container.getInsets()); return result; } }