public Dimension maximumLayoutSize(Container target){
  Dimension rd, mbd;
  Insets i=rootPane.getInsets();
  Container contentPane=rootPane.getContentPane();
  JMenuBar menuBar=rootPane.getJMenuBar();
  if (menuBar != null && menuBar.isVisible()) {
    mbd=menuBar.getMaximumSize();
  }
 else {
    mbd=new Dimension(0,0);
  }
  if (contentPane != null && contentPane.isVisible()) {
    rd=contentPane.getMaximumSize();
  }
 else {
    rd=new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE - i.top - i.bottom- mbd.height- 1);
  }
  return new Dimension(Math.min(rd.width,mbd.width) + i.left + i.right,rd.height + mbd.height + i.top+ i.bottom);
}

public Dimension maximumLayoutSize ( Container target ) { Dimension rd , mbd ; Insets i = rootPane . getInsets ( ) ; Container contentPane = rootPane . getContentPane ( ) ; JMenuBar menuBar = rootPane . getJMenuBar ( ) ; if ( menuBar != null && menuBar . isVisible ( ) ) { mbd = menuBar . getMaximumSize ( ) ; } else { mbd = new Dimension ( 0 , 0 ) ; } if ( contentPane != null && contentPane . isVisible ( ) ) { rd = contentPane . getMaximumSize ( ) ; } else { rd = new Dimension ( Integer . MAX_VALUE , Integer . MAX_VALUE - i . top - i . bottom - mbd . height - 1 ) ; } return new Dimension ( Math . min ( rd . width , mbd . width ) + i . left + i . right , rd . height + mbd . height + i . top + i . bottom ) ; }
returns the maximum amount of space the layout can use .
