title: My JTextArea continues on for infinity, despite adding a LineWrap etc
body: <p>package swingtraining;</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import static java.awt.Color.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import static javafx.scene.paint.Color.TEAL;
  import static javax.swing.JFrame.EXIT_ON_CLOSE;
  
  public class MyFrame extends JFrame{
  
  public MyFrame(){
  
  
      setSize(500,500);
      setVisible(true);
      setResizable(true);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
  };
  
  public static class MyPanel extends JPanel{
  
  public MyPanel(){
  
      setLayout(new GridBagLayout());
  
      setBackground(BLACK);
      setOpaque(true);
  
      GridBagConstraints gbc1 = new GridBagConstraints();
      GridBagConstraints gbc2 = new GridBagConstraints();
  
      gbc1.insets = new Insets(200,0,0,200);
      gbc1.ipadx = 100;
      gbc1.ipady = 100;
      gbc1.gridx = 1;
      gbc1.gridy = 1;
  
      gbc2.insets = new Insets(0,200,200,0);
      gbc2.ipadx = 150;
      gbc2.ipady = 10 ;
      gbc2.gridx = 1;
      gbc2.gridy = 1;
  
      JTextArea jta1 = new JTextArea();
  
      jta1.setLineWrap(true);
      jta1.setWrapStyleWord(true);
  
      JButton jb1 = new JButton("Have a banana!");
  
      jb1.setToolTipText("Button prints Banana.");
  
      ActionListener action1 = new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
  
              System.out.println("\nBananas!");
  
          }
      };
  
  
      jb1.addActionListener(action1);
  
  
  
      add(jta1,gbc2);
      add(jb1,gbc1);
  
  
      };
  
  
  
  };
  
   public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
  
                  MyFrame jf1 = new MyFrame();
                  MyPanel jp1 = new MyPanel();
                  jf1.add(jp1);
  
              }
          });
      }   
  }
  </code></pre>
  
  <p>The code is just a simple JFrame, Panel, with a Button that prints bananas, and a JTextArea. When typed into without the LineWrap etc, it simply extends itself depending on which direction input is being applied. (pressing enter to go down in the area pulls it upwards/downwards, and typing into it pulls it to the left and to the right, making it bigger.) This makes sense, I didn't add a LineWrap or anything. However, adding those;</p>
  
  <pre><code>jta1.setLineWrap(true);
  jta1.setWrapStyleWord(true);
  </code></pre>
  
  <p>I get the following result;</p>
  
  <p>Just a picture to show what I'm talking about:</p>
  
  <p><a href="https://i.stack.imgur.com/OMYtm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OMYtm.png" alt="http://i.stack.imgur.com/OMYtm.png"></a></p>
  
  <p>What I'm aiming for is a JTextArea that has limits, when those are exceeded creates a scrollbar, and doesn't change size at all.</p>
  
  <p>Suggestions?</p>