Dimension (Container target) { Container parent = SwingUtilities.getUnwrappedParent(target); int maxWidth = parent.getWidth() - (parent.getInsets().left + parent.getInsets().right); return getDimension(target, maxWidth); }