/* Example of TextField and TextArea classes */ import java.awt.*; import java.applet.*; public class TextTest extends Applet { Panel p; TextArea ta; TextField from; TextField to; Button replace = new Button("Replace"); public void init() { setLayout(new BorderLayout()); p = new Panel(); p.setLayout(new FlowLayout()); p.add(replace); from = new TextField(10); p.add(from); p.add(new Label("with")); to = new TextField(10); p.add(to); add("South", p); ta = new TextArea(8,40); add("Center", ta); } public boolean action(Event evt, Object arg) { if (arg.equals("Replace")) { String f = from.getText(); int n = ta.getText().indexOf(f); if (n >= 0 && f.length() > 0) ta.replaceText(to.getText(), n, n + f.length()); return true; } return false; } }