太甲

 

计算器

import java.awt.*;

1.实现简单的计算器界面

2.用到布局管理器中的一些常用的,如GridLayout,FlowLayout
public class LoginFrame extends Frame{
 public LoginFrame()
 {
     super("计算器");
     this.setSize(200,300);
     this.setLocation(300,240);
     this.setBackground(Color.lightGray);
     this.setLayout(new GridLayout());
     this.setLayout(new  GridLayout(5,6));
     String str[]={"MC","MR","MS","M-","M+","7","8","9","/","4","5","6","*","1","2","3","-","0",".","=","+"};
     for(int i=0;i<str.length;i++)
      this.add(new Button(str[i]));
     this.setVisible(true);
 }
    public static void main(String[] args) {new LoginFrame();}
}

 

posted on 2017-07-09 11:48  太甲  阅读(104)  评论(0编辑  收藏  举报

导航