Import
Java. AWT .*;
ImportJava. AWT. event .*;
ImportJavax. Swing .*;
PublicClassJtextarea2 {
PublicStaticVoidMain (string []ARGs ){
JframeF = newJframe ("jtextarea2 ");
ContainerContentpane = f. getcontentpane ();
Contentpane. setlayout (NewBorderlayout ());
JpanelP1 = newJpanel ();
P1.setlayout (NewGridlayout (1, 1 ));
P1.setborder (borderfactory. createtitledborder ("construct textarea-use gridlayout, add scrollbar "));
JtextareaT1 = newJtextarea (5, 25 );
T1.settabsize (10 );
T1.setfont (NewFont ("", Font. Bold, 16 ));
T1.setlinewrap (true); // enable the line feed function
T1.setwrapstyleword (true); // activate the word breaking Function
P1.add (NewJscrollpane (T1); // place jtextarea in jscrollpane, so that you can see that the input height exceeds the height of jtextarea through the scrolling Effect
// Text.
Contentpane. Add (P1 );
F. Pack ();
F. Show ();
F. addwindowlistener (NewWindowadapter (){
PublicVoidWindowclosing (receivweventE ){
System. Exit (0 );
}
});
}
}