资源简介
java swing(jdk版本10)实现的图形化界面计算器,已实现记忆功能,阶乘功能,幂次计算,可以进行带括号的复杂运算
代码片段和文件信息
package caculate;
import java.awt.*;
import java.awt.event.*;
import java.math.BigInteger;
//import java.util.HashSet;
//import java.util.Set;
//import java.util.Stack;
import java.util.*;
import javax.swing.*;
//import com.sun.xml.internal.ws.api.server.AbstractServerAsyncTransport;
public class caculator extends Jframe{
/*
* 图形化界面设计
* */
public int tag = 0;
public String mem = ““;
private static final long serialVersionUID = 4907149509182425824L;
// 用于存放一个正括号的集合 用于简化代码
static Set brace = new HashSet<>();
public static void main(String[] args) {
// 初始化正括号集合
brace.add(‘{‘);
brace.add(‘(‘);
brace.add(‘[‘);
new caculator();
}
public caculator(){
Container c = getContentPane(); //定义一个顶级容器c
setLayout(new GridLayout(21));//新建网格布局管理器,2行1列
JTextField jtf = new JTextField(“0“40);//构造一个用指定文本和列初始化的新文本框--jtf
jtf.setHorizontalAlignment(JTextField.RIGHT);//设置水平对齐方式:居右对齐
JButton data0 = new JButton(“0“);
JButton data1 = new JButton(“1“);
JButton data2 = new JButton(“2“);
JButton data3 = new JButton(“3“);
JButton data4 = new JButton(“4“);
JButton data5 = new JButton(“5“);
JButton data6 = new JButton(“6“);
JButton data7 = new JButton(“7“);
JButton data8 = new JButton(“8“);
JButton data9 = new JButton(“9“);
JButton lbbrac = new JButton(“[“);
JButton rbbrac = new JButton(“]“);
JButton plus = new JButton(“+“);
JButton minus = new JButton(“-“);
JButton lbrac = new JButton(“(“);
JButton rbrac = new JButton(“)“);
JButton mtp = new JButton(“*“);
JButton dvd = new JButton(“/“);
JButton jiecheng = new JButton(“!“);
JButton root = new JButton(“^“);
JButton tg = new JButton(“退格“);
JButton MEM = new JButton(“MEM“);
JButton point = new JButton(“.“);
JButton equ = new JButton(“=“);
JButton AC = new JButton(“AC“);
JPanel jp = new JPanel(); //新建JPanel面板--jp
jp.setLayout(new GridLayout(5555));//新建网格布局管理器(行数,列数,组件间的水平垂直间距)
jp.add(data7);
jp.add(data8);
jp.add(data9);
jp.add(plus);
jp.add(jiecheng);
jp.add(data4);
jp.add(data5);
jp.add(data6);
jp.add(minus);
jp.add(root);
jp.add(data1);
jp.add(data2);
jp.add(data3);
jp.add(mtp);
jp.add(MEM);
jp.add(data0);
jp.add(lbrac);
jp.add(rbrac);
jp.add(dvd);
jp.add(tg);
jp.add(point);
jp.add(lbbrac);
jp.add(rbbrac);
jp.add(equ);
jp.add(AC);
c.add(jtf);//将文本框jtf添加到顶级容器c中
c.add(jp);//将JPanel面板jp添加到顶级容器c中
setLocation(440 150);
setSize(400300);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-09-19 19:36 caculate\
文件 390 2018-09-19 19:35 caculate\.classpath
文件 384 2018-09-19 19:35 caculate\.project
目录 0 2018-09-19 19:35 caculate\.settings\
文件 642 2018-09-19 19:35 caculate\.settings\org.eclipse.jdt.core.prefs
目录 0 2019-02-11 15:12 caculate\caculate\
文件 1258 2019-02-11 15:21 caculate\caculate\caculator$1.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$10.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$11.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$12.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$13.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$14.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$15.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$16.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$17.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$18.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$19.class
文件 1297 2019-02-11 15:21 caculate\caculate\caculator$2.class
文件 1299 2019-02-11 15:21 caculate\caculate\caculator$20.class
文件 1107 2019-02-11 15:21 caculate\caculate\caculator$21.class
文件 810 2019-02-11 15:21 caculate\caculate\caculator$22.class
文件 1433 2019-02-11 15:21 caculate\caculate\caculator$23.class
文件 1401 2019-02-11 15:21 caculate\caculate\caculator$24.class
文件 1957 2019-02-11 15:21 caculate\caculate\caculator$25.class
文件 1297 2019-02-11 15:21 caculate\caculate\caculator$3.class
文件 1297 2019-02-11 15:21 caculate\caculate\caculator$4.class
文件 1297 2019-02-11 15:21 caculate\caculate\caculator$5.class
文件 1297 2019-02-11 15:21 caculate\caculate\caculator$6.class
文件 1297 2019-02-11 15:21 caculate\caculate\caculator$7.class
文件 1297 2019-02-11 15:21 caculate\caculate\caculator$8.class
文件 1297 2019-02-11 15:21 caculate\caculate\caculator$9.class
............此处省略2个文件信息
- 上一篇:JAVA入门实验单机版单词测试程序
- 下一篇:蓝牙串口助手APP
评论
共有 条评论