资源描述:
《用java编写的具有保存计算过程的计算器.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、jisuan.javaimportjavax.swing.JMenuBar;publicclassjisuan{publicstaticvoidmain(String[]args){jisqji=newjisq();}}jisq.javaimportjava.awt.Color;importjava.awt.Component;importjava.awt.Font;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;
2、importjava.io.BufferedReader;importjava.io.BufferedWriter;importjava.io.File;importjava.io.FileWriter;importjava.io.IOException;importjava.io.StringReader;importjava.text.SimpleDateFormat;importjava.util.*;importjavax.swing.*;importjavax.swing.border.Bev
3、elBorder;importjavax.swing.border.SoftBevelBorder;publicclassjisqextendsJFrameimplementsActionListener{JPanelpane=newJPanel();Strings,s1,s2;doublet1,t2,t=0;JTextFieldfiel,show;JTextAreaarea;JButtonb0,b1,b2,add,b3,b4,b5,b6,b7,b8,sub,b9,mul,dele,equ,dev;JB
4、uttonsqrt,pow,random,sin,p,log,zf,tui,save,clear,copy,point;publicjisq(){init();this.setBounds(123,143,500,330);this.setTitle("计算器");this.setVisible(true);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Menumenu=newMenu();thi
5、s.setJMenuBar(menu);}voidinit(){JLabeldangqian=newJLabel();pane.setLayout(null);this.add(pane);Datenow=newDate();dangqian.setText(now.toString());SimpleDateFormatri=newSimpleDateFormat("dd");//封装为了获取日期SimpleDateFormatshi=newSimpleDateFormat("kk");//封装为了获
6、取小时SimpleDateFormatfen=newSimpleDateFormat("mm");//封装为了获取分钟SimpleDateFormatmiao=newSimpleDateFormat("ss");//封装为了获取秒钟intriqi=Integer.parseInt(ri.format(now));//获取日期intshizhong=Integer.parseInt(shi.format(now));//获取小时intfenzhong=Integer.parseInt(fen.format
7、(now));//获取分钟intmiaozhong=Integer.parseInt(miao.format(now));//获取秒钟dangqian.setBounds(170,7,553,22);pane.add(dangqian);area=newJTextArea();JScrollPanescrollPane=newJScrollPane(area,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR
8、_AS_NEEDED);scrollPane.setBounds(280,70,200,140);area.setEditable(false);pane.add(scrollPane);fiel=newJTextField();fiel.setBounds(10,30,250,30);fiel.setEditable(false);fiel.setFont(newFont("TimesRoman",Font.BOLD,16));//显示框