Point (@NotNull Component aContainer, @NotNull Dimension contentSize) { final JComponent component = getTargetComponent(aContainer); Rectangle visibleBounds = component != null ? component.getVisibleRect() : new Rectangle(aContainer.getSize()); Point containerScreenPoint = visibleBounds.getLocation(); SwingUtilities.convertPointToScreen(containerScreenPoint, aContainer); visibleBounds.setLocation(containerScreenPoint); return UIUtil.getCenterPoint(visibleBounds, contentSize); }