//Echo //takes stuff from a text field, copies it to a label import java.awt.*; import java.applet.*; public class Echo extends Applet{ //create some components. Label lblOut = new Label(); TextField txtIn = new TextField(); Button btnOK = new Button("OK"); public void init(){ //this is a METHOD that will happen when the applet first loads //it is commonly used to add components to the screen //the following line tells the applet how I want things arranged setLayout(new GridLayout(3,1)); //add the components add(lblOut); add(txtIn); add(btnOK); } // end init public boolean action(Event e, Object o){ //this method will occur whenever an action //(like clicking a button) happens //make a string variable called temp String temp; //check to see if the OK button has been pressed if (e.target == btnOK){ //copy the value of the text field to temp temp = txtIn.getText(); //copy the value of temp to the label lblOut.setText(temp); //tell the calling routine we were successful return true; } else { //if anything else happened.. tell the calling routine that. return false; } // end if } // end action } // end class def