title: Using BoxLayout as vertical FlowLayout to hold JPanel
body: <p>I want to have a vertical <code>FlowLayout</code> to host my <code>JPanels</code>. A lot of ppl suggest using <code>BoxLayout</code>. However, I realize its behavior is not exactly same as <code>FlowLayout</code></p>
  
  <h2>FlowLayout</h2>
  
  <p><img src="https://i.stack.imgur.com/yGYuL.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/gGIDx.png" alt="enter image description here"></p>
  
  <h2>BoxLayout with Y axis</h2>
  
  <p><img src="https://i.stack.imgur.com/mIyeJ.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/gOuJB.png" alt="enter image description here"></p>
  
  <p>As you can see, in <code>FlowLayout</code>, when I stretch parent panel's width, its child panels' width remains the same.</p>
  
  <p>However, in <code>BoxLayout</code>, when I stretch parent panel's height, <strong>its child panels' height changed!</strong>. This seems to have similar behavior as 1 column 2 rows <code>GridLayout</code>. This is not what I want.</p>
  
  <p>Is there any way to prevent this?</p>
  
  <p>I try to have vertical filler on the top and bottom of parent panel.</p>
  
  <pre><code>new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
  </code></pre>
  
  <p>But it doesn't help much. My 2 child panels' height still stretch along when I change parent's height.</p>