资源描述:
《带有进制转换的计算器java源码》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、带有八进制和十六进制转换的计算器截图importjava.awt.*;importjava.awt.event.*;classThis_number_too_bigextendsException{}//自定义的一个结果溢出异常类classJsp2003extendsFrameimplementsItemListener,ActionListener{publicJsp2003(){addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();System.exit(0);}});
2、}staticJsp2003mainFrame=newJsp2003();staticLabellab=newLabel("0");staticPanelpnl1=newPanel(newGridLayout(4,3,3,3));staticPanelpnl2=newPanel(newGridLayout(4,1,3,3));staticPanelpnl3=newPanel(newGridLayout(1,2,3,3));staticPanelpnl4=newPanel(newGridLayout(6,1,3,3));staticButtonbt9=newButton("9");stat
3、icButtonbt8=newButton("8");staticButtonbt7=newButton("7");staticButtonbt6=newButton("6");staticButtonbt5=newButton("5");staticButtonbt4=newButton("4");staticButtonbt3=newButton("3");staticButtonbt2=newButton("2");staticButtonbt1=newButton("1");staticButtonbt0=newButton("0");staticButtonbtdot=newB
4、utton(".");staticButtonbtequ=newButton("=");staticButtonbtadd=newButton("+");staticButtonbtsub=newButton("-");staticButtonbtmul=newButton("*");staticButtonbtdev=newButton("/");staticButtonbtA=newButton("A");staticButtonbtB=newButton("B");staticButtonbtC=newButton("C");staticButtonbtD=newButton("D
5、");staticButtonbtE=newButton("E");staticButtonbtF=newButton("F");staticCheckboxckb8=newCheckbox("八进制");staticCheckboxckb10=newCheckbox("十进制");staticCheckboxckb16=newCheckbox("十六进制");staticButtonbtc=newButton("clear");staticButtonbtt=newButton("backspace");publicintnumber=0,length=18;//number是用来记录
6、输入的数字个数,length是用来设置在不同进制下允许输入的最多数字位数,默认为十进制publiccharmark='n';//设置运算符号为没有即为‘n’,它的值是‘+’‘-’‘*’‘/’publicdoubledata=0;//设置运算数据为零publiccharch;//用来临时存放所按按钮的第一个字符publicbooleanRefresh=false;//设置lab是否要在输入数据的时候刷新,初始为否publicstaticvoidmain(Stringargs[]){System.out.println("StartingJsp2003...");lab.setAlignme
7、nt(Label.RIGHT);lab.setBackground(Color.lightGray);lab.setForeground(Color.BLUE);lab.setFont(newFont("Serief",Font.BOLD,18));lab.setBounds(14,33,216,40);mainFrame.add(lab);CheckboxGroupgrp=newCheckboxGroup();ckb8.setCh