习题2-3
实验程序:
package student;
import java.awt.Graphics;
import java.applet.Applet;
public class ExerciseTwo extends Applet
{
public void paint(Graphics g)
{
g.drawString("Weclome to Java Applet World!",10,20);
}
}
例题2-5
实验程序:
package student;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class ExerciseThree extends Applet implements ActionListener { Label prompt;
TextField input,output;
public void init() {
prompt=new Label("请输入您的名字:");
input=new TextField(6);
output=new TextField(20);
add(prompt);
add(input);
add(output);
input.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
output.setText(input.getText()+",欢迎你!");
}
}
例题2-9
实验程序:
package student;
import java.io.*;
public class ExerciseFour {
public static void main(String[] args) {