title: The size of a JTextArea
body: <p>I have a set of <code>JPanel</code>'s within a <code>JFrame</code>. One of the panels contains a <code>JTextArea</code>. At the moment I create this like so:</p>
  
  <pre><code>JTextArea = new JTextArea(5, 40);
  </code></pre>
  
  <p>And this gives me a text area which is 5 rows by (roughly) 40 columns. </p>
  
  <p>Vertically this works as I'd like it to, the area fills the entire height of the parent container - probably because the parent is the only element positioned in that row.</p>
  
  <p>Horizontally the parent width is determined by elements underneath and it is (usually) wider than the <code>JTextArea</code> is. So I end up with a text area with large margins on either side. What is worse, when I resize the frame smaller to the point where the text area is exactly the width of the parent container, it suddenly 'flicks' and changes into a text area that is 1 row high and is then the width of the parent.</p>
  
  <p>Excuse the crude drawing below which hopefully illustrates the issue.</p>
  
  <p><a href="https://i.stack.imgur.com/w8JtJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w8JtJ.png" alt="enter image description here"></a></p>
  
  <p>In short: How to I create a <code>JTextArea</code> that always fills the maximum space available to it? (and if possible with a minimum width after which a scrollbar appears if the user sizes the frame even smaller)</p>