WelcomeCanvas.java
上传用户:anders
上传日期:2022-07-15
资源大小:376k
文件大小:1k
源码类别:

J2ME

开发平台:

Java

  1. package phoneLeter;
  2. import javax.microedition.lcdui.Canvas;
  3. import javax.microedition.lcdui.Command;
  4. import javax.microedition.lcdui.CommandListener;
  5. import javax.microedition.lcdui.Displayable;
  6. import javax.microedition.lcdui.Graphics;
  7. import javax.microedition.lcdui.Font;
  8. //欢迎界面
  9. public class WelcomeCanvas extends Canvas implements CommandListener {
  10. private Command cmdPhone=new Command("通讯录",Command.SCREEN,1);
  11. private Command cmdExit=new Command("退出",Command.EXIT,1);
  12. private phoneMIDlet pm;
  13. public WelcomeCanvas(phoneMIDlet pm)
  14. {
  15. this.pm=pm;
  16. this.addCommand(cmdPhone);
  17. this.addCommand(cmdExit);
  18. this.setCommandListener(this);
  19. }
  20. protected void paint(Graphics arg0) {
  21. // TODO Auto-generated method stub
  22. String str="欢迎光临";
  23. arg0.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_LARGE));
  24. arg0.setColor(255,0,0);
  25. arg0.drawString(str,this.getWidth()/2,50,Graphics.TOP|Graphics.HCENTER);
  26. }
  27. public void commandAction(Command arg0, Displayable arg1) {
  28. if(arg0==cmdPhone)
  29. {
  30. pm.changeInterface("phoneList");
  31. }
  32. else if(arg0==cmdExit)
  33. {
  34. pm.notifyDestroyed();
  35. }
  36. }
  37. }