八达网

标题: 保存代码 [打印本页]

作者: 诸葛亮    时间: 2009-3-25 14:02
标题: 保存代码
rerererererererrtrtr

新建 Microsoft Word 文档.rar

5.4 KB, 下载次数: 7


作者: xhb221    时间: 2009-3-25 14:04
提示: 作者被禁止或删除 内容自动屏蔽
作者: yirankuyu    时间: 2009-3-25 14:22
提示: 作者被禁止或删除 内容自动屏蔽
作者: 海风依依    时间: 2009-3-25 14:26
什么东西???
作者: luccer    时间: 2009-3-25 14:28
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;


public class Midlet extends MIDlet        implements        CommandListener {
          private Display display;//显示对象的引用
          Command        okCommand;
          Command        exitCommand;
          int        viewType;
          List        list;
          canvasDraw        canvasdraw;
          public Midlet() {
                          canvasdraw=new        canvasDraw();
                          display=Display.getDisplay(this);
                        okCommand=new        Command("确认",Command.OK,2);
                        exitCommand=new        Command("离开",Command.EXIT,2);
                        list=new        List("线条几何形状绘制清单",List.IMPLICIT);
                        list.addCommand(okCommand);
                        list.addCommand(exitCommand);
                        list.append("绘制线条",null);
                        list.append("绘制矩形",null);
                        list.append("绘制圆角矩形",null);
                        list.append("绘制弧形",null);
                        list.append("绘制三角形",null);
                        list.append("绘制文本",null);
                        list.append("绘制图象",null);
                        list.addCommand(okCommand);
                        list.addCommand(exitCommand);
                        list.setCommandListener(this);
                                }       
          protected void startApp() {
         
             display.setCurrent(list);       
        }
          public        void        pauseApp(){}
          public        void        destroyApp(boolean        unconditional){}
          public        void        commandAction(Command        cmd,Displayable        disp){
                  viewType=list.getSelectedIndex();
                  if(cmd==okCommand)
                  {
                        display.setCurrent(canvasdraw);
                  }
                  else        if(cmd==exitCommand){
                          destroyApp(false);
                  }
          }
        class canvasDraw extends Canvas        implements        CommandListener{
                int        action=0;
                Image        handImage;
                int        changeSD=1;
                int        changeFull=0;
                Command        backCommand;
                public        canvasDraw(){
                        try{
                                handImage=Image.createImage("/hand.png");
                        }catch(Exception        ex){}
                        backCommand=new        Command("返回",Command.BACK,1);
                        addCommand(backCommand);
                        setCommandListener(this);
                }
               
                public        void paint(Graphics g)
                {
                        g.setColor(0xffffff);
                        g.fillRect(0,0,getWidth(),getHeight());
                        g.setColor(0);
                        if(viewType==0){
                                g.setColor(0x000000);
                                g.drawLine(10,10,getWidth() -20,10);
                                g.setColor(0xcdab00);
                                g.setStrokeStyle(Graphics.DOTTED);
                                g.drawLine(10,50,getWidth() -20,50);
                        }
                        if(viewType==1){
                                g.setColor(0xff0000 );
                                g.drawRect(10,25,getWidth() - 20,20);
                                g.setColor(0xffff00);
                                g.fillRect(11,26,getWidth() - 22,18);
                                g.setColor(0xff0000 );
                                g.drawRect(10,65,getWidth() - 20,20);
                                g.setColor(0xffff00);
                                g.fillRect(11,96,getWidth() - 22,18);
                               
                        }
                        else        if(viewType==2){
                                g.setColor(0x0000ff);
                                g.drawRoundRect(10,50,getWidth() -20,40,20,20);
                                g.setColor(0x00ffff);
                                g.fillRoundRect(10,100,getWidth() - 20,40,20,20 );
                               
                        }
                        else        if(viewType==3)
                        {
                                g.setColor(0xff0000);
                                g.drawArc(getWidth() / 2 - getWidth() / 8 ,
                                                getHeight() / 2 - getWidth() / 8,
                                                getWidth() / 4 ,        getWidth() /4 ,
                                                0,360);
                                g.setColor(0x00ff00);
                                g.fillArc(40,40,40,40,0,270 );       
                               
                        }
                        else        if(viewType==4)
                        {       
                                g.setColor(0x00ff00);
                                g.fillTriangle(40,40,100,40,60,100);
                        }
                        else        if(viewType==5)
                        {       
                                g.drawString("做好拉",150,
                                                150,Graphics.HCENTER|Graphics.TOP);
                        }
                        else        if(viewType==6)
                        {
                                g.drawImage(handImage,
                                                0, 0, Graphics.LEFT |Graphics.TOP );
                        }
                }
                public        void        commandAction(Command        cmd,Displayable        disp)
                {
                        if(cmd==backCommand)
                                display.setCurrent(list);
                }
        }
}







欢迎光临 八达网 (https://www.8-da.com/) Powered by Discuz! X2.5