title: Border Layout not taking up all available space
body: <p>I'm new to swing, and I suspect the issue has something to do with the BoxLayout. I'm trying to make a series of textfields and labels be one after the other on top of a frame. This is my code:</p>
  
  <pre><code>public static void main(String[] args) {
      JFrame frame = new JFrame("New Message");
      frame.setSize(100, 100);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      JTextArea textArea = new JTextArea();
      frame.add(textArea, BorderLayout.CENTER);
  
      JPanel list = new JPanel();
      list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS));
      frame.add(list, BorderLayout.NORTH);
  
      String[] labels = {"To: ", "Cc: ", "Bcc: ", "Subject: "};
      for (int i = 0; i &lt; labels.length; i++) {
          JLabel l = new JLabel(labels[i]);
          JTextField f = new JTextField();
          JPanel p = new JPanel();
          p.add(l, BorderLayout.WEST);
          p.add(f, BorderLayout.CENTER);
          list.add(p);
      }
  
      frame.pack();
  
      frame.setVisible(true);
  
  }
  </code></pre>
  
  <p>This is the result:
  <img src="https://i.stack.imgur.com/R8Q9I.png" alt="enter image description here"></p>
  
  <p>What I want is the To, Cc, Bcc and Subject to be all the way on the left and the TextField to take up the rest of the space.</p>