⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcan.java

📁 j2me ,手机
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */import javax.microedition.lcdui.*;//import javax.microedition.lcdui.TextField;/** * @author YUANYUEXIANG */public class PCan extends Canvas implements CommandListener {    /**     * constructor     */     Command cd;     char[] zf=new char[4];     char[] aj=new char[4];     Image img1;     Image img2;     Image img3;     Image bz;     Image tc;     Image yy;     static int x;     static int y;     int action1=5;     int action2=0;     int action3=0;     boolean f=true;     public static boolean isrunning=true;     boolean gb=true;     boolean qd=true;     TextField text=null;     StringBuffer str1;     public static StringBuffer str2=new StringBuffer("");     public int m;     public int n;     public int L=0;     public int H=12;     public static PCan instance;     public static StringBuffer strcx=new StringBuffer("");     public static StringBuffer strcx1=new StringBuffer("");     public static StringBuffer strcx2=new StringBuffer("");     public CXex cx=new CXex();      //////////////////////////////////////////////////////////////    public PCan() {       try{	    setCommandListener(this);	    cd=new Command("Exit", Command.EXIT, 0);	    //addCommand(cd);        } catch(Exception e) {            e.printStackTrace();        }        try{        img1=Image.createImage("/menu.png");        img2=Image.createImage("/bj.png");        img3=Image.createImage("/Java.png");       yy=Image.createImage("/yy.png");       bz=Image.createImage("/bz.png");       tc=Image.createImage("/tc.png");        }        catch(Exception e){}               this.setFullScreenMode(true);       x=8;       y=48;       m=0;       n=0;       str1=new StringBuffer("请输入一个单词:");       str2=new StringBuffer("");       aj[0]=' ';       aj[1]=' ';       aj[2]=' ';       aj[3]=' ';       XC xc=new XC();       xc.start();       XC1 xc1=new XC1();       xc1.start();       XC2 xc2=new XC2();       xc2.start();       cx.CXex0();       /////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////    }        ////////////////////////////////////////////////////////////////////    public void paint(Graphics g) {        g.drawImage(img2,0,0,Graphics.TOP|Graphics.LEFT);        g.setColor(123, 2, 2);        g.drawLine(0, 133, 240, 133);        g.setColor(1, 2, 234);        g.drawLine(80, 0, 80, 320);        g.setColor(0, 255, 0);        g.drawLine(m-120, 133, m, 133);        g.drawLine(80, n-160, 80, n);      ///////////////////////////////////////////////////////        g.fillRoundRect(110, 150+L*L, 20, 20, 20, 20);        g.fillRoundRect(110, 166+H*H, 20, 20, 20, 20);//.fillRect(0, 200, 10, 120);        /////////////////////////////////////////////////////        g.setColor(0, 255, 0);        g.drawArc(75, 128, 10, 10, 0, 360);        g.drawArc(70, 123, 20, 20, 0, 360);        g.drawArc(65, 118, 30, 30, 0, 360);        g.drawArc(60, 113, 40, 40, 0, 360);        /////////////////////////////////////////////////////////////+action            g.setColor(222,222,222);            g.drawImage(yy,5+action1,50,Graphics.TOP|Graphics.LEFT);            //g.drawString("英语词典", 25+action1,50,Graphics.TOP|Graphics.LEFT);            g.drawImage(bz,5+action2,75,Graphics.TOP|Graphics.LEFT);            //g.drawString("帮助文档", 25+action2,75,Graphics.TOP|Graphics.LEFT);            g.drawImage(tc,5+action3,100,Graphics.TOP|Graphics.LEFT);            //g.drawString("退出程序", 25+action3,100,Graphics.TOP|Graphics.LEFT);       //////////////////////////////////////////////////////////////             if(gb==true){            g.setColor(255, 0,0);            //g.drawRoundRect(x, y, 67, 25,8,8);            //g.fillRect(x, y, 67, 25);            }       /////////////////////////////////////////////////////////////                   /////////////////////////////////////////////////////////////            if(y==48){            action1=10;            action2=0;            action3=0;            g.setColor(255, 0,0);            g.drawRoundRect(84, 65, 100, 15, 8, 8);            g.drawString(str1.toString(), 85, 50, Graphics.TOP|Graphics.LEFT);            g.drawString(str2.toString()+"_", 89, 65, Graphics.TOP|Graphics.LEFT);                                                /////////////////////////////////////////////////////////////////            g.setColor(255,255,0);            //g.drawString("字符选项:", 85,85,Graphics.TOP|Graphics.LEFT);            /////////////////////////////////////////////////////////////////            g.setColor(255,255,156);            g.drawChar(zf[0], 135, 85,Graphics.TOP|Graphics.LEFT);            g.drawChar(zf[1], 145, 85,Graphics.TOP|Graphics.LEFT);            g.drawChar(zf[2], 155, 85,Graphics.TOP|Graphics.LEFT);            g.drawChar(zf[3], 165, 85,Graphics.TOP|Graphics.LEFT);            //////////////////////////////////////////////////////////////////            g.setColor(255,100,0);            //g.drawString("对应按键:", 85, 100,Graphics.TOP|Graphics.LEFT);            /////////////////////////////////////////////////////////////////            g.setColor(1,255,255);            g.drawChar(aj[0], 135, 100,Graphics.TOP|Graphics.LEFT);            g.drawChar(aj[1], 145, 100,Graphics.TOP|Graphics.LEFT);            g.drawChar(aj[2], 155, 100,Graphics.TOP|Graphics.LEFT);            g.drawChar(aj[3], 165, 100,Graphics.TOP|Graphics.LEFT);            /////////////////////////////////////////////////////////////////            g.setColor(255,0,255);            g.drawRoundRect(10, 155, 174, 80, 8, 8);            g.setColor(255,222,222);            g.drawString(strcx.toString(), 11, 160,Graphics.TOP|Graphics.LEFT);            g.drawLine(13, 175, 180, 175);            g.drawString(strcx1.toString(), 11, 185,Graphics.TOP|Graphics.LEFT);            g.drawLine(13, 200, 180, 200);            g.setColor(255,0,0);            g.drawString(strcx2.toString(), 11, 210,Graphics.TOP|Graphics.LEFT);            /////////////////////////////////////////////////////////////////            }            if(y==73){            action1=0;            action2=10;            action3=0;            g.setColor(255, 0,0);            g.drawString("大学英语四级电子词典,", 85, 50, Graphics.TOP|Graphics.LEFT);            g.drawString("欢迎下载,欢迎使用^_^", 85, 75, Graphics.TOP|Graphics.LEFT);            g.drawString("                  叶飘零", 85, 100, Graphics.TOP|Graphics.LEFT);            g.drawString("            QQ:814709880", 85, 115, Graphics.TOP|Graphics.LEFT);            }            if(y==98){            action1=0;            action2=0;            action3=10;            g.setColor(255, 0,0);            g.drawString("请按确认键,欢迎再来!", 85, 50, Graphics.TOP|Graphics.LEFT);            }    }    ////////////////////////////////////////////////////////////////////       //////////////////////////////////////////////////////////////////////////////    public class XC extends Thread {        boolean isrunning0=true;        public void run() {            while(isrunning0==true){                        if(gb==true){gb=false;            }else{gb=true;}            if(m<360){            m+=3;            }else{            m=0;            }            if(n<500){            n+=5;            }else{n=0;}            repaint();            try{                Thread.sleep(50);                }            catch(Exception e){}            }                    }    }    ////////////////////////////////////////////////////////////////////////    ///////////////////////////////////////////////////////////////////////    public class XC1 extends Thread {                        public void run() {            while(isrunning==true){                if(L<12){                L++;                }                                else{L=0;isrunning=true;                               }            repaint();            try{                Thread.sleep(150);                }            catch(Exception e){}            }                    }    }    ///////////////////////////////////////////////    public class XC2 extends Thread {                       public void run() {            while(isrunning==true){                                if(H>0){                H--;                }else{H=12;isrunning=true;}            repaint();            try{                Thread.sleep(150);                }            catch(Exception e){}            }                    }    }    ///////////////////////////////////////////////////////////////////////////////    /**     * Called when a key is pressed.     */    protected  void keyPressed(int kc) {             if(kc==-1){     if(y<=48){     y=98;     }else{     y-=25;     }     }     if(kc==-2){     if(y>=98){     y=48;     }else{     y+=25;     }     }               ////////////////////////////////////////////////////     if(kc==PCan.KEY_NUM2){     zf[0]='a';        zf[1]='b';     zf[2]='c';     zf[3]=' ';       aj[0]='*';       aj[1]='0';       aj[2]='#';       aj[3]=' ';     }     if(kc==PCan.KEY_NUM3){     zf[0]='d';        zf[1]='e';     zf[2]='f';     zf[3]=' ';       aj[0]='*';       aj[1]='0';       aj[2]='#';       aj[3]=' ';     }     if(kc==PCan.KEY_NUM4){     zf[0]='g';        zf[1]='h';     zf[2]='i';     zf[3]=' ';       aj[0]='*';       aj[1]='0';       aj[2]='#';       aj[3]=' ';     }     if(kc==PCan.KEY_NUM5){     zf[0]='j';        zf[1]='k';     zf[2]='l';     zf[3]=' ';       aj[0]='*';       aj[1]='0';       aj[2]='#';       aj[3]=' ';     }     if(kc==PCan.KEY_NUM6){     zf[0]='m';        zf[1]='n';     zf[2]='o';     zf[3]=' ';       aj[0]='*';       aj[1]='0';       aj[2]='#';       aj[3]=' ';     }     if(kc==PCan.KEY_NUM7){     zf[0]='p';        zf[1]='q';     zf[2]='r';     zf[3]='s';       aj[0]='*';       aj[1]='0';       aj[2]='#';        aj[3]='1';      }     if(kc==PCan.KEY_NUM8){     zf[0]='t';        zf[1]='u';     zf[2]='v';     zf[3]=' ';       aj[0]='*';       aj[1]='0';       aj[2]='#';        aj[3]=' ';     }     if(kc==PCan.KEY_NUM9){     zf[0]='w';        zf[1]='x';     zf[2]='y';     zf[3]='z';       aj[0]='*';       aj[1]='0';       aj[2]='#';        aj[3]='1';      }     ////////////////////////////////////////////////        if(kc==PCan.KEY_STAR){        str2.insert(str2.length(), zf[0]);           }        if(kc==PCan.KEY_NUM0){        str2.insert(str2.length(), zf[1]);           }        if(kc==PCan.KEY_POUND){        str2.insert(str2.length(), zf[2]);           }        if(kc==PCan.KEY_NUM1){        str2.insert(str2.length(), zf[3]);           }     /////////////////////////////////////////////////     if(kc==-3){         if(str2.length()>=1){           str2.deleteCharAt(str2.length()-1);         }         else{}     }     if(kc==-4){           //cx.commandAction();         str2.append(' ');     }     //////////////////////////////////////////////////     if(y==48){     //CXex cx=new CXex();         if(kc!=-5)     cx.CXex0();     }     ///////////////////////////////////////////////////      if(kc==-5){     if(y==48){     //cx.sstr(str2.toString());     //cx.d.setString(str2.toString());     //CXex cx=new CXex();      cx.commandAction();     //cx.d.setString(str2.toString());     //cx.d.setString("a");     //cx.itemStateChanged(text);     }     if(y==73){}     if(y==98){     Mdzcd.instance.destroyApp(true);     Mdzcd.instance.notifyDestroyed();     Mdzcd.instance=null;     }     }     isrunning=true;     //if(y==48){     //CXex cx=new CXex(); }     //////////////////////////////////////////////////    this.repaint();    //str2=new StringBuffer();    //strcx=new StringBuffer(" ");    }    protected  void keyRepeated(int kc) {        if(kc==-3){        str2.delete(0, str2.length());        }    }    public void commandAction(Command cmd, Displayable displayable) {    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -