zoukankan      html  css  js  c++  java
  • 第四十次发博不知道用什么标题好

    一个超级简单的可以使用的

     1 package Test;
     2 import java.awt.*;
     3 import java.awt.event.ActionEvent;
     4 import java.awt.event.ActionListener;
     5 
     6 import javax.swing.*;
     7 
     8 public class Count {
     9 JFrame f;
    10 JPanel p;
    11 JTextField tf1,tf2,tf3;
    12 JLabel l1,l2,l3,l4;
    13 JButton b1,b2;
    14 
    15 public Count() {
    16     f = new JFrame();
    17     p = new JPanel();
    18     tf1 = new JTextField(10);
    19     tf2 = new JTextField(10);
    20     tf3 = new JTextField(10);
    21     
    22     l1 = new JLabel("加数1");
    23     l2 = new JLabel("加数2");
    24     l3 = new JLabel();
    25     l4 = new JLabel();
    26     b1 = new JButton("求和");
    27     b2 = new JButton("清除");
    28     
    29     f.setVisible(true);
    30     f.setBounds(550, 200, 300, 300);
    31     p.setLayout(new GridLayout(3,3));
    32     f.add(p);
    33     
    34     p.add(l1);
    35     p.add(tf1);
    36     p.add(l3);
    37     
    38     p.add(l2);
    39     p.add(tf2);
    40     p.add(l4);
    41     
    42     p.add(b1);
    43     p.add(tf3);
    44     p.add(b2);
    45 
    46     b1.addActionListener(new ActionListener() {
    47         
    48         @Override
    49         public void actionPerformed(ActionEvent e) {
    50             int a = Integer.parseInt(tf1.getText());
    51             int b = Integer.parseInt(tf2.getText());
    52             tf3.setText(a+b+"");
    53             
    54             // TODO Auto-generated method stub
    55             
    56         }
    57     });
    58     b2.addActionListener(new ActionListener() {
    59         
    60         @Override
    61         public void actionPerformed(ActionEvent e) {
    62             tf1.setText(null);
    63             tf2.setText(null);
    64             tf3.setText(null);
    65             
    66             // TODO Auto-generated method stub
    67             
    68         }
    69     });
    70 }
    71 
    72     public static void main(String[] args) {
    73         new Count();
    74         // TODO Auto-generated method stub
    75 
    76     }
    77 
    78 }
     1 package Test;
     2 import java.awt.*;
     3 import java.awt.event.ActionEvent;
     4 import java.awt.event.ActionListener;
     5 
     6 import javax.swing.*;
     7 
     8 public class Count {
     9 JFrame f;
    10 JPanel p;
    11 JTextField tf1,tf2,tf3;
    12 JLabel l1,l2,l3,l4;
    13 JButton b1,b2;
    14 
    15 public Count() {
    16     f = new JFrame();
    17     p = new JPanel();
    18     tf1 = new JTextField(10);
    19     tf2 = new JTextField(10);
    20     tf3 = new JTextField(10);
    21     
    22     l1 = new JLabel("加数1");
    23     l2 = new JLabel("加数2");
    24     l3 = new JLabel();
    25     l4 = new JLabel();
    26     b1 = new JButton("求和");
    27     b2 = new JButton("清除");
    28     
    29     f.setVisible(true);
    30     f.setBounds(550, 200, 300, 300);
    31     p.setLayout(new GridLayout(3,3));
    32     f.add(p);
    33     
    34     p.add(l1);
    35     p.add(tf1);
    36     p.add(l3);
    37     
    38     p.add(l2);
    39     p.add(tf2);
    40     p.add(l4);
    41     
    42     p.add(b1);
    43     p.add(tf3);
    44     p.add(b2);
    45 
    46     b1.addActionListener(new ActionListener() {
    47         
    48         @Override
    49         public void actionPerformed(ActionEvent e) {
    50             int a = Integer.parseInt(tf1.getText());
    51             int b = Integer.parseInt(tf2.getText());
    52             tf3.setText(a+b+"");
    53             
    54             // TODO Auto-generated method stub
    55             
    56         }
    57     });
    58     b2.addActionListener(new ActionListener() {
    59         
    60         @Override
    61         public void actionPerformed(ActionEvent e) {
    62             tf1.setText(null);
    63             tf2.setText(null);
    64             tf3.setText(null);
    65             
    66             // TODO Auto-generated method stub
    67             
    68         }
    69     });
    70 }
    71 
    72     public static void main(String[] args) {
    73         new Count();
    74         // TODO Auto-generated method stub
    75 
    76     }
    77 
    78 }

    计算器

  • 相关阅读:
    Sanic二十七:Sanic + tortoise-orm 之Q对象
    Sanic二十六:Sanic + tortoise-orm 之Model、QuerySet提供的查询方法
    Sanic二十五:Sanic + tortoise-orm 之表关联
    Sanic二十四:Sanic + tortoise-orm 之常用字段类型和参数
    Sanic二十三:Sanic + tortoise-orm 之父类Field的参数、属性、方法
    Sanic二十二:Sanic + tortoise-orm 之使用aerich执行数据库迁移
    Sanic二十一:Sanic + tortoise-orm 之模型定义
    [JavaScript]Promise:异步编程
    手把手教你搭建一个SpringBoot工程
    Android 11(R) Power HAL AIDL简析 -- 基本接口
  • 原文地址:https://www.cnblogs.com/shi-yuan/p/10965489.html
Copyright © 2011-2022 走看看