欢迎来到天天文库
浏览记录
ID:8810799
大小:21.50 KB
页数:2页
时间:2018-04-08
《java编程实现模拟手机界面功能》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、importjava.applet.*;importjava.awt.*;importjava.awt.event.*;publicclassCellphoneextendsAppletimplementsActionListener{Buttonarraybtn[]=newButton[13];Stringbtns[]={"1","2","3","4","5","6","7","8","9","0","·¢ËÍ","Çå³ý","¹Ø»ú","",""};TextFieldoutput=new
2、TextField(5);PanelbtnPanel=newPanel();publicvoidinit(){btnPanel.setLayout(newGridLayout(5,3));for(inti=0;i<13;i++){arraybtn[i]=newButton(btns[i]);arraybtn[i].addActionListener(this);btnPanel.add(arraybtn[i]);}setLayout(newBorderLayout());add("North",
3、output);add("Center",btnPanel);output.setText("");}publicvoidactionPerformed(ActionEvente){if(e.getSource()instanceofButton){charc=((Button)(e.getSource())).getLabel().charAt(0);switch(c){case'1':output.setText(output.getText()+"1");break;case'2':out
4、put.setText(output.getText()+"2");break;case'3':output.setText(output.getText()+"3");break;case'4':output.setText(output.getText()+"4");break;case'5':output.setText(output.getText()+"5");break;case'6':output.setText(output.getText()+"6");break;case'7
5、':output.setText(output.getText()+"7");break;case'8':output.setText(output.getText()+"8");break;case'9':output.setText(output.getText()+"9");break;case'0':output.setText(output.getText()+"0");break;default:;}if((Button)(e.getSource())==arraybtn[10])o
6、utput.setText(output.getText()+"²¦ºÅÖÐ...");elseif((Button)(e.getSource())==arraybtn[11])output.setText("");elseif((Button)(e.getSource())==arraybtn[12])System.exit(0);}}}
此文档下载收益归作者所有