简单小程序!
这是图形界面下的基本输入输出applet程序,其源程序如下:
import java.applet.Applet;
import java.awt.*;
public class SimpleGraphicsInOut extends Applet
{
Label prompt;
TextField input;
Label output;
public void init()
{
prompt=new Label("Enter a character please:");
input=new TextField(3);
output=new Label(" ");
add(prompt);
add(input);
add(output);
}
public boolean action(Event e,Object o)
{
output.setText("You've entered character "+ o.toString());
return true;
}
}
编译通过,但是有警告,但运行结果:输入没问题,可输出只有“You've entered ”,不知道是为什么?还有就是书上运行结果,两个语句会换行,可我的运行结果没有!请大家帮忙看看!谢谢!