if (minimumSize != null && prefSize != null && (minimumSize.width > prefSize.width || minimumSize.height > prefSize.height)) prefSize = new Dimension(Math.max(minimumSize.width, prefSize.width), Math.max(minimumSize.height, prefSize.height));
  public Dimension getPreferredSize()  {    Dimension prefSize = null;    if (preferredSize != null)      prefSize = preferredSize;    else if (ui != null)      {        Dimension s = ui.getPreferredSize(this);        if (s != null)          prefSize = s;      }    if (prefSize == null)      prefSize = super.getPreferredSize();    // make sure that prefSize is not smaller than minSize    if (minimumSize != null && prefSize != null        && (minimumSize.width > prefSize.width            || minimumSize.height > prefSize.height))        prefSize = new Dimension(Math.max(minimumSize.width, prefSize.width),                                 Math.max(minimumSize.height, prefSize.height));    return prefSize;  }