当前位置:   article > 正文

Java 用 GUI实现简易计算器(为了方便实现,仅支持两个数间的运算,如果读者想设计一个支持N个数之间的运算,可以考虑中缀转后缀,然后用栈来实现)_计算器gui

计算器gui
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Objects;

public class study_11_23_1
{
   
    public static void main(String[] args) {
   
        Window win = new Window(); //创建窗口
        win.setBounds(300,300,300,500);
    }
}
class Window extends JFrame
{
   
    buttonEvent be ; // action监听器

    JTextArea textArea = new JTextArea(15,25);//文本域
    JButton button0 = new  JButton("0");//各种按钮
    JButton button1 = new  JButton("1");
    JButton button2 = new  JButton("2");
    JButton button3 = new  JButton("3");
    JButton button4 = new  JButton("4");
    JButton button5 = new  JButton("5");
    JButton button6 = new  JButton("6");
    JButton button7 = new  JButton("7");
    JButton button8 = new  JButton("8");
    JButton button9 = new  JButton("9");
    JButton buttona = new JButton("+");
    JButton buttons = new JButton("-");
    JButton buttonm = new JButton("*");
    JButton buttond = 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/275652
推荐阅读
相关标签
  

闽ICP备14008679号