title: How to make a JPanel expand to max width in another JPanel
body: <p>I feel I need to rephrase the question a bit. </p>
  
  <p><em><strong>Updated question below.</em></strong></p>
  
  <p>I have a JPanel that contains:</p>
  
  <pre><code>myjpanel.setLayout(new BoxLayout(selectors, BoxLayout.PAGE_AXIS));
  </code></pre>
  
  <p><strong>It contains the following three panels:</strong></p>
  
  <p>JPanel with fixed size 'x' and 'y'</p>
  
  <p>JPanel with no fixed size</p>
  
  <p>JPanel with no fixed size and small height</p>
  
  <p>The second JPanel contains a JTable so it expands to fill the full height and pushes the bottom panel all the way down, as expected.</p>
  
  <p><em>Like this:</em></p>
  
  <pre><code>t
  t
  m
  m
  m
  m
  m
  b
  </code></pre>
  
  <p>t = top panel,
  m = middle panel,
  b = bottom panel.</p>
  
  <p>That works. But the bottom panel does not feel like filling the entire width of the parent which is a problem.</p>
  
  <pre><code>ttt
  mmm
   b 
  </code></pre>
  
  <p>I would like  either this, where the panel fills the entire width:</p>
  
  <pre><code>ttt
  mmm
  bbb
  </code></pre>
  
  <p>or this, where the bottom panel is left centered:</p>
  
  <pre><code>ttt
  mmm
  b
  </code></pre>
  
  <hr>
  
  <p><em><strong>Old question below:</em></strong></p>
  
  <p>I have a JPanel that contains:</p>
  
  <pre><code>.setLayout(new BoxLayout(selectors, BoxLayout.PAGE_AXIS));
  </code></pre>
  
  <p>Within it, there are three more JPanels. The first two are of fixed size and the middle one isn't.</p>
  
  <p>I want my bottom panel to take only the height it needs, but uses all the available width of the outer JPanel.</p>
  
  <p>I have tried using glue but to no avail, and I would rather not set preferred and min/max sizes.
  Is there a way to tell the component to "Fill the entire parents width" using just the layout manager and framework. I would rather not start to do hacks like setting sizes and overriding methods.</p>
  
  <p><strong>Note:</strong> I can't put any glue or filler in the inner panel, only the outer panel and its layout manager can be modified.</p>
  
  <p><em>Attempt 1:</em></p>
  
  <p>Using <code>myPanel.setLayout(new GridLayout(3, 1));</code> did not produce the expected results. It made a grid like this:</p>
  
  <pre><code>XX
   X
  </code></pre>
  
  <p>But I expected:</p>
  
  <pre><code>X
  X
  X
  </code></pre>
  
  <p><em>Attempt 2:</em></p>
  
  <p>Using <code>myPanel.setLayout(new GridLayout(0,1));</code> did not produce the expected results. It made a grid like this:</p>
  
  <pre><code>x
  x
  x
  </code></pre>
  
  <p>But all panels were of the same size, ignoring the restraints.</p>