Awt program for finding starting and ending position
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet
code="TextArea2" height=200 width=200>
</applet>
*/
public class TextArea2 extends Applet implements
ActionListener
{
TextArea
ta;
TextField
tsp,tep;
public
void init()
{
Label
l1=new Label("Enter the text :");
add(l1);
ta=new
TextArea(10,50);
add(ta);
Label
l2=new Label("Starting Position :");
add(l2);
tsp=new
TextField(20);
add(tsp);
Label
l3=new Label("Ending Position :");
add(l3);
tep=new
TextField(20);
add(tep);
Button
b=new Button("Select");
add(b);
b.addActionListener(this);
}
public
void actionPerformed(ActionEvent ae)
{
/*get
and set the starting position of the selection */
int
sposition=Integer.parseInt(tsp.getText());
/*get
and set the ending position of the selection */
int
eposition=Integer.parseInt(tep.getText());
/*select
the text */
ta.select(sposition,eposition);
}
}
Comments
Post a Comment