synchronized (this) { if (prefSize == null) {
Dimension prefSize = new Dimension();
    public Dimension preferredLayoutSize(Container c)    {      // We must synchronize here, otherwise we cannot guarantee that the      // prefSize is still non-null when returning.      synchronized (this)        {          if (prefSize == null)            {              Insets i = getInsets();              prefSize = new Dimension(i.left + i.right, i.top + i.bottom);              Dimension contentPrefSize = contentPane.getPreferredSize();              prefSize.width += contentPrefSize.width;              prefSize.height += contentPrefSize.height;          if (menuBar != null)            {                  Dimension menuBarSize = menuBar.getPreferredSize();                  if (menuBarSize.width > contentPrefSize.width)                    prefSize.width += menuBarSize.width - contentPrefSize.width;                  prefSize.height += menuBarSize.height;            }        }          // Return a copy here so the cached value won't get trashed by some          // other component.          return new Dimension(prefSize);      }    }