EnterString.java

Entering a String at the keyboard and Outputting with the setText method
/*EnterString.java


< applet
code=EnterString
width=200
height=200 >
< /applet >



The purpose of this applet is to demonstrate how to
input a String at the Keyboard.*/
import java.applet.*;
import java.awt.*;

public class EnterString extends Applet
{
	TextField nameFld=new TextField(20);
	TextArea result=new TextArea(3, 20);
	
	public void init()
	{
           add(new Label("Enter name:"));
           add(nameFld);
           add(new Button("See name"));
           add(result);
	}

	public boolean action(Event clickedButton, Object Name)
	{
           String name=new String();
           name=nameFld.getText();
           result.setText("Your name is: "+name+"\n");
           return true;
	}
}


Sample Output for EnterString.java