一、源代码
package jisuanqi2;
import java.awt.*;
public class Jisuanqi extends Frame{
public Jisuanqi() {
super("计算器");
this.setSize(400,100);
this.setLocation(300,240);
this.setLayout(new FlowLayout());
this.add(new TextField("10",8));
this.add(new Label("+"));
this.add(new TextField("20",8));
this.add(new Button("="));
this.add(new TextField(10));
this.setVisible(true);
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
new Jisuanqi();
}
}
结果: