/* if size of top-level window wasn't set then just set contentPane and menuBar to its preferred sizes. Otherwise, if the size of top-level window was specified then set menuBar to its preferred size and make content pane to fit into the remaining space
    public void layoutContainer(Container c)    {      Dimension menuBarSize;      int containerWidth = c.getBounds().width - getInsets().left                           - getInsets().right;      int containerHeight = c.getBounds().height - getInsets().top                            - getInsets().bottom;      Dimension contentPaneSize = contentPane.getPreferredSize();      // 1. the glassPane fills entire viewable region (bounds - insets).      // 2. the layeredPane filles entire viewable region.      // 3. the menuBar is positioned at the upper edge of layeredPane.      // 4. the contentPane fills viewable region minus menuBar, if present.            /*       if size of top-level window wasn't set then just set       contentPane and menuBar to its preferred sizes.       Otherwise, if the size of top-level window was specified then       set menuBar to its preferred size and make content pane       to fit into the remaining space       +-------------------------------+       |  JLayeredPane                 |       |  +--------------------------+ |       |  | menuBar                  | |       |  +--------------------------+ |       |  +--------------------------+ |       |  |contentPane               | |       |  |                          | |       |  |                          | |       |  |                          | |       |  +--------------------------+ |       +-------------------------------+      */      if (containerWidth == 0 && containerHeight == 0)        {          if (menuBar != null)            {              int maxWidth;              menuBarSize = menuBar.getPreferredSize();              maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);              menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);              glassPane.setBounds(0, 0, maxWidth, menuBarSize.height                                                  + contentPaneSize.height);              contentPane.setBounds(0, menuBarSize.height, maxWidth,                                    contentPaneSize.height);              layeredPane.setBounds(0, 0, maxWidth, menuBarSize.height                                                    + contentPaneSize.height);            }          else            {              glassPane.setBounds(0, 0, contentPaneSize.width,                                  contentPaneSize.height);              contentPane.setBounds(0, 0, contentPaneSize.width,                                    contentPaneSize.height);              layeredPane.setBounds(0, 0, contentPaneSize.width,                                    contentPaneSize.height);            }        }      else        {          if (menuBar != null)            {              menuBarSize = menuBar.getPreferredSize();              if (menuBarSize.height > containerHeight)                menuBarSize.height = containerHeight;              menuBar.setBounds(0, 0, containerWidth, menuBarSize.height);              glassPane.setBounds(0, 0, containerWidth, containerHeight);              contentPane.setBounds(0, menuBarSize.height, containerWidth,                                    (containerHeight - menuBarSize.height));            }          else            {              glassPane.setBounds(0, 0, containerWidth, containerHeight);              contentPane.setBounds(0, 0, containerWidth, containerHeight);            }          layeredPane.setBounds(0, 0, containerWidth, containerHeight);        }    }