Java Reference
In-Depth Information
import java.applet.*;
import java.awt.*;
public class HelloWorldApplet2 extends Applet
{
private Button go;
private TextField name;
private Label hello;
public void init()
{
String buttonLabel = this.getParameter(“buttonLabel”);
if(buttonLabel == null)
{
//No buttonLabel parameter was defined.
buttonLabel = “Go”;
}
go = new Button(buttonLabel);
String greeting = this.getParameter(“greeting”);
if(greeting == null)
{
greeting = “Hello”;
}
hello = new Label(greeting, Label.CENTER);
this.setLayout(new BorderLayout());
name = new TextField();
this.add(name, BorderLayout.NORTH);
Panel center = new Panel();
center.add(go);
this.add(center, BorderLayout.CENTER);
this.add(hello, BorderLayout.SOUTH);
//setup the event handling
DisplayGreeting listener = new DisplayGreeting(hello, name);
go.addActionListener(listener);
}
}
import java.awt.*;
import java.awt.event.*;
public class DisplayGreeting implements ActionListener
{
private Label label;
private TextField textField;
private String greeting;
public DisplayGreeting(Label s, TextField t)
{
Search WWH ::




Custom Search