}//end itemStateChanged(ItemEvent e) method
//------------------------------------------------------------
//按钮事件的处理
public void actionPerformed(ActionEvent m)
{
Button btn=(Button) m.getSource();
ch=btn.getLabel().charAt(0);
switch (ch)
{ case 'c': {lab.setText("0"); number=0; mark='n'; Refresh=false;}break;//初始化
case '1': enter(); break;
case '2': enter(); break;
case '3': enter(); break;
case '4': enter(); break;
case '5': enter(); break;
case '6': enter(); break;
case '7': enter(); break;
case '8': enter(); break;
case '9': enter(); break;
case '0': {if(Refresh==true) { lab.setText("0"); number=0; Refresh=false; }
if(lab.getText().charAt(0)=='0'&& lab.getText().length()==1)
break;
if(number<length)
{number++;lab.setText(lab.getText()+ch);} else break;
} break;
case 'A': enter(); break;
case 'B': enter(); break;
case 'C': enter(); break;
case 'D': enter(); break;
case 'E': enter(); break;
case 'F': enter(); break;
case '.': {if(Refresh==true) {lab.setText("0"); number=0; Refresh=false;}
if(lab.getText().indexOf('.')== -1)
{number++;lab.setText(lab.getText()+ch);}
else
break;
}
break;
case 'b': {if(number==0) break;
else
{if(--number==0) {lab.setText("0"); number=0;}
else
{if (number!=1) lab.setText(lab.getText().substring(0,number));
else
lab.setText(Character.toString(lab.getText().charAt(0)));}
}
}break;
case '+': try
{ js();}
catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出现异常则初始化效果如同clear键
case '-': try
{ js();}
catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出现异常则初始化效果如同clear键
case '*': try
{ js();}
catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出现异常则初始化效果如同clear键
case '/': try
{ js();}
catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出现异常则初始化效果如同clear键
case '=': try
{ js();}
catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出现异常则初始化效果如同clear键
}
}//end actionPerformed(ActionEvent e) method
//八进制或十辣进制转换成十进制I
//-------------------------------------Infinity
public String goto_10(String s,long l)
//参数s: 是要转换的字符串,由于输入的控制,保证了字符串的合法性;
//参数l: 使用来设置是将8进制还是16进制转换成10进制,它的有效值为8或16;
{
String str=s; //用来转换的字符串
long j=l; //表示进制
long lg=0,jing=1;//lg用来记录权乘和,jing用来记录位权
char cha;//临时记录要转换的字符
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页