title: Chat layout with BoxLayout manager
body: <p>Box layout seems to be quite suitable for the needs of typical chat layout like the one I've made in InkScape.<br>
  <img src="https://i.stack.imgur.com/RIJAW.png" alt="enter image description here"></p>
  
  <p>I have based the structure like this:</p>
  
  <pre><code>MainFrame
    Chat JPanel - BoxLayout.Y_AXIS
      Message list - ScrollablePanel
         the list - BoxLayout.Y_AXIS
      Text field - Just a text field
  </code></pre>
  
  <p>Now the only problem I seem to have is, that in the inital phase, the space is divided 50% to 50% between text field and the message list.</p>
  
  <p><img src="https://i.stack.imgur.com/KHl0V.png" alt="enter image description here"></p>
  
  <p>However, if the message area is filled, as you can see in the image above and I try to resize the chat window, everything goes well:</p>
  
  <p><img src="https://i.stack.imgur.com/zJ5AS.png" alt="enter image description here"></p>
  
  <p>So:</p>
  
  <ol>
  <li>I want the textarea to keep the same size, even when message container is empty.</li>
  <li>There must be a method to be called to simulate me resizing the window so that the panels update properly.</li>
  </ol>
  
  <p>Here is the chat panel:</p>
  
  <pre><code>public class ChatPanel extends JPanel {
      private BoxLayout layout;
      private TextField input;
      private MessageList messages;
      public ChatPanel() {
        layout = new BoxLayout(this, BoxLayout.Y_AXIS);
        setLayout(layout);
        //Create message list
        messages = new MessageList();
        messages.appendTo(this);
        //Create text field
        input = new TextField();
        add(input);
      }
      public void addMessage(String message) {
        messages.addMessage(message);   
      }
      public void appendTo(JFrame frame) {
         frame.getContentPane().add(this);   
      }
  }
  </code></pre>
  
  <p>And here is the messageList:</p>
  
  <pre><code>public class MessageList extends JPanel {
      public MessageList() {
        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  
      }
      public void addMessage(String message) {
        JLabel lb = new JLabel();
        lb.setText(message);
        add(lb);        
        validate();
      }
      public void appendTo(JPanel frame) {
         frame.add(new JScrollPane(this));   
      }
  }
  </code></pre>