+-------------------------------+ |  JLayeredPane                 | |  +--------------------------+ | |  | menuBar                  | | |  +--------------------------+ | |  +--------------------------+ | |  |contentPane               | | |  |                          | | |  |                          | | |  |                          | | |  +--------------------------+ | +-------------------------------+
/* 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;        Dimension containerSize = c.getSize(null);        Dimension contentPaneSize = contentPane.getPreferredSize();          /*         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 (containerSize.width == 0 && containerSize.height == 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, menuBarSize.height, maxWidth,	                          contentPaneSize.height);	        contentPane.setBounds(0, menuBarSize.height, maxWidth,	                              contentPaneSize.height);	        layeredPane.setSize(maxWidth,	                            menuBarSize.height + contentPaneSize.height);	      }	    else	      {	      glassPane.setBounds(0, 0, contentPaneSize.width,	                          contentPaneSize.height);	        contentPane.setBounds(0, 0, contentPaneSize.width,	                              contentPaneSize.height);	        layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);	      }          }        else          {	    if (menuBar != null)	      {	        menuBarSize = menuBar.getPreferredSize();	        if (menuBarSize.height > containerSize.height)		   menuBarSize.height = containerSize.height;	        menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);	        int remainingHeight = containerSize.height - menuBarSize.height;	      glassPane.setBounds(0, menuBarSize.height, containerSize.width,	                          containerSize.height - menuBarSize.height);	        contentPane.setBounds(0, menuBarSize.height,	                              containerSize.width,	                              (containerSize.height - menuBarSize.height));	      }	    else	    {	      glassPane.setBounds(0, 0, containerSize.width,	                          containerSize.height);	      contentPane.setBounds(0, 0, containerSize.width,	                            containerSize.height);	    }	    layeredPane.setSize(containerSize.width, containerSize.height);          }      }