• 实验十


    源代码:

    package ji;

    import java.awt.Button;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.Frame;
    import java.awt.Label;
    import java.awt.TextField;

    import javax.swing.JFrame;

    public class Add extends JFrame{
    //private static final int ON = 0;
    //private static final int CLOSE = 0;
    public Add() {
    super("运算器");
    this.setSize(400,200);
    this.setLocation(300,240);
    this.setBackground(Color.white);

    this.setLayout(new FlowLayout());

    this.add(new TextField("10",8));
    this.add(new Label("+"));
    this.add(new TextField("20",8));
    this.add(new Button("="));
    this.add(new TextField(10));

    this.add(new TextField("30",8));
    this.add(new Label("-"));
    this.add(new TextField("20",8));
    this.add(new Button("="));
    this.add(new TextField(10));

    this.add(new TextField("10",8));
    this.add(new Label("*"));
    this.add(new TextField("20",8));
    this.add(new Button("="));
    this.add(new TextField(10));

    this.add(new TextField("10",8));
    this.add(new Label("/"));
    this.add(new TextField("2",8));
    this.add(new Button("="));
    this.add(new TextField(10));

    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public static void main(String[]arg)
    {
    new Add();
    }
    }

    运行结果:

    心得:

    对本次实验花了很多时间,但还是理解不够深刻,只能做出基本的窗口和按钮等等,对如何运算现在还不懂,希望能在接下来的学习中学习到。

  • 相关阅读:
    Spring系列(六):Spring事务源码解析
    Spring系列(五):Spring AOP源码解析
    Spring系列(四):Spring AOP详解
    Spring系列(三):Spring IoC源码解析
    Spring IoC源码解析之getBean
    Spring IoC源码解析之invokeBeanFactoryPostProcessors
    Spring系列(二):Spring IoC应用
    HDU-1276
    Codeforces Round #410 (Div. 2)-A
    ubuntu16.04安装wps
  • 原文地址:https://www.cnblogs.com/myb1128/p/10965038.html
Copyright © 2020-2023  润新知