The question is simple. Get the strings in jtextarea and jtextfield, perform the operation, and put the result in another jtextarea.
Import javax. Swing .*;
Import java. AWT .*;
Import java. AWT. event .*;
Import static util. swingconsole .*;
Import java. util. RegEx .*;
Public class textarea extends jframe
{
Private jbutton B = new jbutton ("click ");
Private jtextarea T1 = new jtextarea (5, 10 );
Private jtextarea t2 = new jtextarea (5, 10 );
Private jtextfield TF = new jtextfield (10 );
Public textarea ()
{
B. addactionlistener (New actionlistener (){
Public void actionreceivmed (actionevent e ){
String name = t1.gettext ();
String Match = TF. gettext ();
Pattern P = pattern. Compile (MATCH );
Matcher M = P. matcher (name );
T2.settext (""); // used to clear Initialization
While (M. Find ())
{
T2.append ("Match \" "+ M. group () + "\" at positions "+ M. start () + "-" + (M. end ()-1) + "\ n ");
}
}});
Setlayout (New flowlayout ());
Add (New jscrollpane (T1 ));
Add (B );
Add (New jscrollpane (T2 ));
// Add (B );
Add (TF );
}
Public static void main (string [] ARGs)
{
Run (New textarea (), 475,425 );
}
}