预览加载中,请您耐心等待几秒...
1/6
2/6
3/6
4/6
5/6
6/6

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

//计算器 importjava.awt.*; importjava.awt.event.*; importjavax.swing.*; publicclassCalculatorextendsWindowAdapterimplementsActionListener{ JFrameframe; JTextFieldshow; JButtonbc,ce,c,ab,jia,jian,cheng,chu,equ,point,sqrt,zf,bfh,ds; //退格,复位,清空,关于,加,减,乘,除,等,点,2,加减,百分之,倒数 JButtonb[]=newJButton[10];//保存数字 JDialogabout; finalintlength=30; inti=0,j=0,action=0,p=0;//记录数字键连续时间次数 doublenum=0,getValue;//记录计算结果的值,保存值 publicCalculator(){ frame=newJFrame("计算器"); frame.addWindowListener(this); frame.setSize(360,230); frame.setLocation(380,260); frame.setLayout(newFlowLayout(FlowLayout.CENTER)); frame.setResizable(false); show=newJTextField(31); show.setText("0"); show.setHorizontalAlignment(SwingConstants.RIGHT); show.setEnabled(false); frame.add(show); PaneldispTop=newPanel(); frame.add(dispTop); dispTop.setLayout(newGridLayout(1,4,3,3)); bc=newJButton("BACK"); bc.addActionListener(this); dispTop.add(bc); ce=newJButton("CE"); ce.addActionListener(this); dispTop.add(ce); c=newJButton("C"); c.addActionListener(this); dispTop.add(c); ab=newJButton("ABOUT"); ab.addActionListener(this); dispTop.add(ab); //about弹出框 about=newJDialog(frame,"关于计算器",true); about.addWindowListener(this); JLabellabel=newJLabel("http://www.itzcn.com",JLabel.CENTER); about.add(label); about.setSize(200,100); about.setLocation(500,300); //数据显示区 PaneldispMain=newPanel(); frame.add(dispMain); dispMain.setLayout(newGridLayout(1,2,10,10)); //按钮左面板 PaneldispLeft=newPanel(); frame.add(dispLeft); dispLeft.setLayout(newGridLayout(4,3,3,3));//四行三列 //按钮右面板 PaneldispRight=newPanel(); frame.add(dispRight); dispRight.setLayout(newGridLayout(4,2,3,3));//四行两列 for(intl=9;l>=0;l--){ b[l]=newJButton(String.valueOf(l)); dispLeft.add(b[l]); b[l].addActionListener(this); } zf=newJButton("+/-"); zf.addActionListener(this); dispLeft.add(zf); point=newJButton("."); point.addActionListen