title: Java : divide the screen
body: <p>I try to do a simple swing window, but with the layout it's not easy... 
  I mean I just want a window with 3 panels :</p>
  
  <ul>
  <li>header with 20% of window in height</li>
  <li>content with 60% of window in height</li>
  <li>footer with 20% of window in height</li>
  </ul>
  
  <p>But I can't succeed to have what I want. I used a gridLayout(3,1) but I can't specify the height. </p>
  
  <pre><code>public class Window extends JFrame implements Serializable  {
  private JPanel _header;
  private JPanel _content;
  private JPanel _footer;
  
  public Window() {
      GridLayout grid = new GridLayout(3,1);
      setLayout(grid);
  
      _header = new JPanel();
      _header.setBackground(Color.GRAY);
      getContentPane().add(_header);
  
      _content = new JPanel();
      JScrollPane jsp = new JScrollPane(_content, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      getContentPane().add(jsp);
  
      _footer = new JPanel();
      _footer.setBackground(Color.GRAY);
      getContentPane().add(_footer);
      pack();
      validate();
  
      setTitle("Chat client");
      setVisible(true);
      setSize(500, 500);
      setLocationRelativeTo(null);
  }
  </code></pre>
  
  <p>Can you help me ? 
  Best regards</p>