immutableImageDemo.java
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:2k
源码类别:

J2ME

开发平台:

Java

  1. package immutableimagedemo;
  2. import javax.microedition.lcdui.*;
  3. import javax.microedition.midlet.*;
  4. public class immutableImageDemo extends MIDlet implements CommandListener
  5. {
  6.         private Display display;
  7.         private ImageCanvas myCanvas;
  8.         private Command  arrayCmd = new Command("从数组读取", Command.SCREEN, 1);
  9.         private Command   fileCmd = new Command("从文件读取", Command.SCREEN, 1);
  10.         private Command streamCmd = new Command("从输入流读取",Command.SCREEN, 1);
  11.         private Command  transCmd = new Command(" 翻转图像", Command.SCREEN, 1);
  12.         private Command clarityCmd= new Command(" 透明图像", Command.SCREEN, 1);
  13.         private Command   exitCmd = new Command(" 退出", Command.SCREEN, 1);
  14.         public immutableImageDemo()
  15.         {
  16.          myCanvas = new ImageCanvas();
  17.                 display = Display.getDisplay(this);
  18.                 myCanvas.addCommand(arrayCmd);
  19.                 myCanvas.addCommand(fileCmd);
  20.                 myCanvas.addCommand(streamCmd);
  21.                 myCanvas.addCommand(transCmd); 
  22.                 myCanvas.addCommand(clarityCmd);
  23.                 myCanvas.addCommand(exitCmd);                                
  24.                 myCanvas.setCommandListener(this);
  25.         }
  26.         public void startApp()
  27.         {
  28.                 
  29.                  display.setCurrent(myCanvas);
  30.         }
  31.         public void pauseApp()
  32.         {
  33.         }
  34.         public void destroyApp(boolean unconditional)
  35.         {
  36.         }
  37.         public void commandAction(Command cmd, Displayable disp) {
  38.         if(cmd == exitCmd){
  39.         destroyApp(false);
  40.         notifyDestroyed();
  41.         return;
  42.         }
  43.         if (cmd == arrayCmd){
  44.         myCanvas.type = myCanvas.ARRAY;
  45.         }
  46.         else if(cmd == fileCmd){
  47.         myCanvas.type = myCanvas.FILE;        
  48.         }
  49.         else if(cmd == streamCmd){
  50.         myCanvas.type = myCanvas.STREA;
  51.         }
  52.         else if(cmd == transCmd){
  53.         myCanvas.type = myCanvas.TRANS;
  54.         }
  55.         else if(cmd == clarityCmd){
  56.         myCanvas.type = myCanvas.CLARITY;
  57.         }
  58.         myCanvas.repaint();
  59.         
  60.         }
  61. }