《java编程实现模拟手机界面功能》由会员分享,可在线阅读,更多相关《java编程实现模拟手机界面功能(2页珍藏版)》请在金锄头文库上搜索。
1、import java.applet.*;import java.awt.*;import java.awt.event.*;public class Cellphone extends Applet implements ActionListenerButton arraybtn=new Button13;String btns=1,2,3,4,5,6,7,8,9,0,;TextField output=new TextField(5);Panel btnPanel=new Panel();public void init()btnPanel.setLayout(new GridLayout
2、(5,3);for(int i=0;i13;i+)arraybtni=new Button(btnsi);arraybtni.addActionListener(this);btnPanel.add(arraybtni);setLayout(new BorderLayout();add(North,output);add(Center,btnPanel);output.setText();public void actionPerformed(ActionEvent e)if(e.getSource() instanceof Button)char c=(Button)(e.getSource
3、().getLabel().charAt(0);switch(c)case1:output.setText(output.getText()+1);break;case2:output.setText(output.getText()+2);break;case3:output.setText(output.getText()+3);break;case4:output.setText(output.getText()+4);break;case5:output.setText(output.getText()+5);break;case6:output.setText(output.getT
4、ext()+6);break;case7:output.setText(output.getText()+7);break;case8:output.setText(output.getText()+8);break;case9:output.setText(output.getText()+9);break;case0:output.setText(output.getText()+0);break;default:;if(Button)(e.getSource()=arraybtn10)output.setText(output.getText()+.);else if(Button)(e.getSource()=arraybtn11)output.setText();else if(Button)(e.getSource()=arraybtn12)System.exit(0);