Dimension () { Dimension size = new Dimension(); size.height = 0; size.width = TabContentLayout.getTabLayoutStart() + getInsets().left + getInsets().right; for (int i = 0; i < getComponentCount(); i++) { final Component each = getComponent(i); if (each.isVisible()) { size.height = Math.max(each.getPreferredSize().height, size.height); size.width += each.getPreferredSize().width; } } size.width = Math.max(size.width, getMinimumSize().width); return size; }