title: Netbeans JTextArea - change the preferred scrollable viewport size
body: <p>I am creating a GUI with Netbeans that uses JTextAreas to display text content. The content of the JTextAreas may sometimes be long enough to justify scrollbars, but this will not always be the case. Netbeans automatically puts JTextAreas into JScrollPanes for this very issue.</p>
  
  <p>However, my JTextAreas are 40 pixels in height. As the preferredScrollableViewportSize is [194, 94], a scrollbar shows up no matter how long the text in the JTextArea is. I have set the preferredSizes for the JTextArea and the JScrollPane containing it to a height of 35 pixels, but this has done nothing.</p>
  
  <p>The preferredScrollableViewportSize field in the JTextArea properties is greyed out and I can't change it. From code, I can get </p>
  
  <pre><code>jTextArea1.getPrefferedScrollableViewportSize()
  </code></pre>
  
  <p>but there is no equivalent set method. I have tried </p>
  
  <pre><code>jScrollPane1.getViewport().setPreferredSize(new Dimension(10, 10));
  </code></pre>
  
  <p>but this effects no change.</p>
  
  <p>Does anyone know a way to remove the scrollbars except when they are needed?</p>