码迷,mamicode.com
首页 > 其他好文 > 详细

实现计算器的界面

时间:2017-05-16 23:08:05      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:ring   str   new   nbsp   ges   out   bsp   images   技术   

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();}
}

 技术分享

实现计算器的界面

标签:ring   str   new   nbsp   ges   out   bsp   images   技术   

原文地址:http://www.cnblogs.com/wjm0910/p/6863952.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!