@Override
    public Dimension getPreferredSize() {
      if (isPreferredSizeSet()) {
        return super.getPreferredSize();
      }
      final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
      Point p = null;
      if (focusOwner != null && focusOwner.isShowing()) {
        p = focusOwner.getLocationOnScreen();
      }

      return computeNotBiggerDimension(super.getPreferredSize().getSize(), p);
    }
@Override
    public Dimension getPreferredSize()