title: JScrollBar Vertical/Horizontal setting problem- Java Swing
body: <p>I am just trying to add a vertical scroll bar to my TextField and TextArea.
  I am using a ScrollPane and it should create  avertical/horizontal scroll bar by default.</p>
  
  <p>Problem:
  I need a vertical scroll bar to see the data which is not visible.
  In the start a vertical scrollbar appears but when the data increases the vertical scrollbar changes to a horizontal scroll bar.
  Also the TextField disappears and only a horizontal scrollbar appears in its place.
  I guess it is because how I have set the bounds but I tried changing the bounds and it ends up completely doing away with the TextField.</p>
  
  <p>My code snippet:</p>
  
  <pre><code>public JTextField inputField = new JTextField();
  
  public  JTextArea talkArea = new JTextArea();
  
  public JScrollPane inputFieldScroll = new JScrollPane(inputField);
  
  public JScrollPane talkAreaScroll = new JScrollPane(talkArea);
        talkArea.setEditable(false);
  
      talkArea.setBackground(Color.white);
  
       talkAreaScroll.setBounds(new Rectangle(TALK_LEFT, TALK_TOP, TALK_WIDTH, TALK_HEIGHT));     
  
       this.getContentPane().add(talkAreaScroll, null);
  
      //set input area
  
        inputField.setBackground(Color.white);
  
      inputField.setBounds(new Rectangle(INPUT_LEFT, INPUT_TOP, INPUT_WIDTH, INPUT_HEIGHT));
  
      inputFieldScroll.setVerticalScrollBar(new JScrollBar());
  
      inputFieldScroll.setBounds(new Rectangle(INPUT_LEFT, INPUT_TOP, INPUT_WIDTH, INPUT_HEIGHT));
  </code></pre>
  
  <p>Question:</p>
  
  <p>Is there some parameter I need to set so that it remains a vertical scroll bar?
  Why does the input scroll bar occupy the whole inputfield when the data becomes a huge line? It appears as a proper vertical scrollbar in the start.</p>
  
  <p>Any advice appreciated.</p>
  
  <p>Thanks </p>