WelcomeCanvas.java
上传用户:anders
上传日期:2022-07-15
资源大小:376k
文件大小:1k
- package phoneLeter;
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Graphics;
- import javax.microedition.lcdui.Font;
- //欢迎界面
- public class WelcomeCanvas extends Canvas implements CommandListener {
- private Command cmdPhone=new Command("通讯录",Command.SCREEN,1);
- private Command cmdExit=new Command("退出",Command.EXIT,1);
- private phoneMIDlet pm;
-
- public WelcomeCanvas(phoneMIDlet pm)
- {
- this.pm=pm;
- this.addCommand(cmdPhone);
- this.addCommand(cmdExit);
- this.setCommandListener(this);
- }
-
- protected void paint(Graphics arg0) {
- // TODO Auto-generated method stub
- String str="欢迎光临";
- arg0.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_LARGE));
- arg0.setColor(255,0,0);
- arg0.drawString(str,this.getWidth()/2,50,Graphics.TOP|Graphics.HCENTER);
- }
- public void commandAction(Command arg0, Displayable arg1) {
- if(arg0==cmdPhone)
- {
- pm.changeInterface("phoneList");
- }
- else if(arg0==cmdExit)
- {
- pm.notifyDestroyed();
- }
- }
- }