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

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

    }

}

java---计算器图形界面(无功能)_第1张图片

你可能感兴趣的:(java,图形,界面)