import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class CopyText extends Applet implements ActionListener { TextField field1, field2; Button enterButton; public void init() { //Create the text field and make it uneditable. field1 = new TextField(); // input TextField (editable) field2 = new TextField(); // an uneditable TextField which field2.setEditable(false); // I'll copy the input string into enterButton = new Button("Enter"); // the button, obviously enterButton.addActionListener(this); // Listen for clicks on the button //Set the layout manager so that the text field will be //as wide as possible. // parameters (3,1) lay the 3 Components in a single column // on the screen setLayout(new java.awt.GridLayout(3,1)); //Add the Components to the applet. add(field1); add(field2); add(enterButton); } // when the Button is clicked, this method is called public void actionPerformed(ActionEvent e) { String instring = field1.getText(); // get text from field1 field2.setText(instring); // copy it into field2 } }