Dimension (Container parent) { assert parent.getComponentCount() == 2; int width = parent.getComponent(0).getPreferredSize().width * 2 + myGap.get() + parent.getComponent(1).getPreferredSize().width; return new Dimension(width, myHeight.get()); }