大二学生利用Java中的GUI编写计算器的简单编用(更适合刚学完Java基础课的大学生)

           计算器是我们身边最常用的工具,针对计算器的编写是很基础的,对于现在自己刚学完Java SE,更多的重要的知识还接触不到,话不多说————请君观阅我的文章 

      以下是计算机的编写代码

 

public class GUIMyFrame {
    public static void show(final JFrame f,final int width,final int height){
        SwingUtilities.invokeLater(new Runnable(){//invokeLater线程异步进行;invokeAndWait线程同步进行。
            public void run(){
                f.setTitle("计算机");
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setSize(width, height);
                f.setVisible(true);
            }
        });
    }
}
public class Jisuan extends JFrame {
    JPanel one,two,three;
    JButton jia,jian,cheng,
            denghao1,chu,kuo1,kuo2,log,ln,q1,q2,q3,q4,q5,q6,q7,q8,q9,q0,dian,qing;
    JTextField jie;
    JLabel denghao;
    JTextArea Area;
    Jisuan(){
        setLayout(new GridLayout(3,1,1,10));
        one = new JPanel();
        two = new JPanel();
        three = new JPanel();
        Area = new JTextArea(10,15);
        jie = new JTextField(15);
        jia = new JButton("+");
        jian = new JButton("-");
        cheng = new JButton("×");
        chu = new JButton("÷");
        denghao = new JLabel("等于",SwingConstants.CENTER);
        denghao1 = new JButton("确认");
        denghao.setForeground(Color.blue);
        denghao1.setForeground(Color.red);
        denghao.setFont(new Font("宋体",Font.BOLD,30));
        jie.setEditable(false);
        log = new JButton("%");
        ln = new JButton("返回");
        q1 = new JButton("1");
        q2 
  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值