java—计算器图形界面(无功能)

原创 陈 浩翔  2015-11-12 03:19  阅读 139 次
package cn.hncu.chx1;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.TextField;

public class jisuanqi extends Frame{

    public jisuanqi(){
        super("计算器");
        String aa[]={"MC","MR","MS","M+","M-","←","CE","C","±","√","7","8","9","/","%","4","5","6","*","1/x","1","2","3","-","=","0",".","+"};
        this.setLocation(400, 300);
        //显示位置
        this.setSize(250, 320);
        //组件宽和高
        this.setBackground(new Color(224,238,238));
        //this.setLayout(new FlowLayout(0));流布局

        Panel p = new Panel();
        //new 一个面板
        p.setSize(230, 30);
        p.setBackground(new Color(230,230,250));
        this.add(p,BorderLayout.NORTH);
        p.add(new Label("查看(V)"));
        p.add(new Label("编辑(E)"));
        p.add(new Label("帮助(H)"));

        this.add(new TextArea(28,10));


        Panel p1 = new Panel();
        p1.setSize(250, 100);
        p1.setBackground(new Color(224,238,238));
        this.add(p1,BorderLayout.SOUTH);
        p1.setLayout(new GridLayout(6, 5,8,8));

        Button btns[];
        btns = new Button[35];
        for(int i=0;i<aa.length;i++){
            btns[i] = new Button(aa[i]);
            p1.add(btns[i]);
        }
        p1.add(new Label(""),26);
        p1.add(new Label(""),28);

        this.setResizable(false);
        //不可以调大小
        setVisible(true);
        //显示组件可见

    }


    public static void main(String[] args) {
        new jisuanqi();

    }

}

anyShare分享到:
本文地址:http://chenhaoxiang.cn/2015/11/12/0319/
关注我们:请关注一下我们的微信公众号:扫描二维码会Java的公众号,公众号:UIFuture
版权声明:本文为原创文章,版权归 陈 浩翔 所有,欢迎分享本文,转载请保留出处!

发表评论


表情