title: Sizing issue with scrollable JTextField
body: <p>I have a form with lots of text fields and some of those text fields may contain very long strings. To make it work I made those text fields scrollable using this code:</p>
  
  <pre><code>JScrollPane scroll = new JScrollPane(textField);
  scroll.setPreferredSize(new Dimension((int)textField.getPreferredSize().getWidth(), (int)textField.getPreferredSize().getHeight() * 2));
  </code></pre>
  
  <p>Then I put scroll into my form using GridBagLayout.</p>
  
  <p>Second line in my example is required for scroller to show up. But it has downside. When I resize window to fit whole text in text field, then scroll disapears leaving me with just two times higher then others text field, which looks ridiculous. 
  How can I make this all work and show me normal size of text field after scroller is hidden?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>You may use following as a demo code to reproduce the issue:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  
  public class ScrollTextDemo extends JFrame{
  
  public  ScrollTextDemo(){
      super();
      this.setPreferredSize(new Dimension(500, 300));
      JPanel panel = new JPanel();
      panel.setLayout(new GridBagLayout());
      JTextField textField = new JTextField("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
      textField.setCursor(new Cursor(0));
      textField.setEditable(false);
      JScrollPane scroll = new JScrollPane(textField);
      scroll.setPreferredSize(new Dimension(70, 40) );
      GridBagConstraints gbc = new GridBagConstraints();
      gbc.gridx = 1;
      gbc.gridy = 1;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.weightx = 0.5;
      gbc.insets = new Insets(5, 5, 0, 5);
      panel.add(scroll,gbc);
      //let's add one more text field without scroll bar to compare
      JTextField textField2 = new JTextField("abc");
      gbc = new GridBagConstraints();
      gbc.gridx = 1;
      gbc.gridy = 2;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.weightx = 0.5;
      gbc.insets = new Insets(5, 5, 0, 5);
      panel.add(textField2,gbc);
      this.add(panel);
  } 
  
  public static void main(String args[]){
      ScrollTextDemo demo = new ScrollTextDemo();
      demo.pack();
      demo.setVisible(true);
  }
  }
  </code></pre>