1,利用AWT组件实现计算器的可视化界面。
2,掌握布局管理器的实现。
3,计算器的实现利用了网页布局管理器。
4,布局管理类的实现要在框架之上进行实现。
5,遇到的问题:实现一个四行四列的计算器,第一次运行的时候是四行四列,第二次运行的时候是三行四列,第三次运行的时候又会恢复之前
正常的四行四列,
import java.awt.*;
public class LoginFrame extends Frame{
public LoginFrame()
{
super("计算器");
this.setSize(200,130);
this.setLocation(300,240);//设置组件的显示位置
this.setBackground(Color.lightGray);//设置组件的背景颜色
this.setVisible(true);//显示框架窗口
this.setLayout(new GridLayout(4,4));
this.add(new Button("7"));
this.add(new Button("8"));
this.add(new Button("9"));
this.add(new Button("/"));
this.add(new Button("4"));
this.add(new Button("5"));
this.add(new Button("6"));
this.add(new Button("*"));
this.add(new Button("1"));
this.add(new Button("2"));
this.add(new Button("3"));
this.add(new Button("-"));
this.add(new Button("0"));
this.add(new Button("."));
this.add(new Button("="));
this.add(new Button("+"));
}
public static void main(String arg[])
{
new LoginFrame();
}
}