Dimension (final JBPopup popup) { Dimension size = null; if (popup instanceof AbstractPopup) { final String dimensionKey = ((AbstractPopup)popup).getDimensionServiceKey(); if (dimensionKey != null) { size = DimensionService.getInstance().getSize(dimensionKey); } } if (size == null) { size = popup.getContent().getPreferredSize(); } return size; }