if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
if (valid && maxSize != null) return new Dimension(maxSize);  LayoutManager layout = getLayout(); if (layout != null && layout instanceof LayoutManager2)
  public Dimension getMaximumSize()  {    if (layoutMgr != null && layoutMgr instanceof LayoutManager2)      {        LayoutManager2 lm2 = (LayoutManager2) layoutMgr;        return lm2.maximumLayoutSize(this);      }    else      return super.getMaximumSize();  }