The ScrollPane doesn't work, and the TextArea just keep getting bigger!

Here is what I did: I made a Frame first. Then I made a TextArea. Then I made a Scroll. Then I made a panel.
Then I add the TextArea and the Scroll to the Panel, and I add the Panel to the Frame, but the whole thing just doesn't work. Anyway, see for it yourself.
Hope someone can find where I did wrong, thank you very much!
import javax.swing.*;
public class TextArea extends JFrame
     public static void main(String[] args)
          new TextArea();
     public TextArea()
          /*Frame*/
          this.setLocation(100, 100);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.setResizable(false);
          /*TextArea*/
          JTextArea text = new JTextArea(10, 50);
          text.setLineWrap(true);
          text.setWrapStyleWord(true);
          text.setEditable(true);
          /*Scroll*/
          JScrollPane Scroll1 = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
          /*Panel*/
          JPanel panel = new JPanel();
          /*Add things together*/
          panel.add(text);
          panel.add(Scroll1);
          this.add(panel);
          this.pack();
          this.setVisible(true);
}

after you make this change, the reasons for your problem
should become clear
    /*Add things together*/
    //panel.add(text);//<-------------remove line
    panel.add(Scroll1);

Similar Messages

Maybe you are looking for

  • How to Publish a report created by Oracle report builder

    Hi Everyone My colleague and I were trying to use the Oracle Reports Builder to replace our existing reports generator from our ERP system. We have already created the report in the Reports Builder from the development suite. What we are looking for

  • [SOLVED]Can't start mpd

    I tried today to setup mpd, so I could connect ncmcpp to it, but it seems that it fails everytime I try to "systemctl start mpd". My config for mpd (/etc/mpd.conf) # Files and directories ####################################################### music_

  • How to locate the "11 Bug"

    Hello, This question Must be post again and again by many fellow , but they are so widely different each other .So , the core problem is : HOW TO LOCATE THE Point where the JVM crash so , if any one could give me a solution or say something about it

  • The screen color just went off when I connect WD thunderbolt and Viewsonic Screen.  What can I do?

    I bought Macbook Air with WD Thunderbolt and Viewsonic screen.  If I connect the screen to Macbook Air, it works.  I connect Hard Drive first and screen connnect to Hard Drive.  The color just went off.  I have try on RGB and DVI.  It has same result

  • Pps files

    Hi all! This is something that doesn't always happen: I've received a pps file which won't open either with PowerPoint or neoOffice apps. PowerPoint stops responding and I must force quit the app as well as force quite the corresponding MS error repo