資源描述:
《星座 跳轉(zhuǎn) (任意鍵跳轉(zhuǎn)和定時跳轉(zhuǎn))》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、Welcomeimportjava.io.IOException;importjava.util.Timer;importjava.util.TimerTask;importjavax.microedition.lcdui.Canvas;importjavax.microedition.lcdui.Command;importjavax.microedition.lcdui.CommandListener;importjavax.microedition.lcdui.Display;importjavax.microedition.lcdu
2、i.Displayable;importjavax.microedition.lcdui.Graphics;importjavax.microedition.lcdui.Image;importjavax.microedition.lcdui.Ticker;publicclassWelcomeextendsCanvasimplementsCommandListener,Runnable{Commandgocmd;Imageimg[]=newImage[2];Threadd=newThread(this);intindex=0;Timerti
3、me=newTimer();Threadxiancheng=newThread(this);Displaydis;Displayabledisp;publicWelcome(Displaydis,Displayabledisp){this.dis=dis;this.disp=disp;Tickert=newTicker("歡迎!");gocmd=newCommand("進入",Command.SCREEN,1);this.addCommand(gocmd);this.setCommandListener(this);this.setTick
4、er(t);try{img[0]=Image.createImage("/_home_4.png");img[1]=Image.createImage("/_home_8.png");}catch(IOExceptione){}d.start();}publicvoidkeyPressed(intk)這兩行是任意鍵跳轉(zhuǎn)不需任意跳轉(zhuǎn)刪掉即可{dis.setCurrent(disp);}publicvoidcommandAction(Commandc,Displayabled){if(c==gocmd){dis.setCurrent(disp)
5、;}}publicvoidshowNotify(){time.schedule(newTimerTask(){publicvoidrun(){time.cancel();dis.setCurrent(disp);}},5000);定時跳轉(zhuǎn)5000代表時間可改動}publicvoidpaint(Graphicsg){g.drawImage(img[index],this.getWidth()/2,this.getHeight()/2+img[index].getHeight()/2,Graphics.BOTTOM
6、Graphics.HCENT
7、ER);}publicvoidrun(){while(true){index++;index%=2;repaint();try{Thread.sleep(200);}catch(Exceptione1){}}}}MainClassimportjava.io.IOException;importjavax.microedition.lcdui.Command;importjavax.microedition.lcdui.CommandListener;importjavax.microedition.lcdui.Display;importj
8、avax.microedition.lcdui.Displayable;importjavax.microedition.lcdui.Image;importjavax.microedition.lcdui.List;importjavax.microedition.midlet.MIDlet;importjavax.microedition.midlet.MIDletStateChangeException;publicclassMainClassextendsMIDletimplementsCommandListener{//priva
9、testaticfinalStringMainList=null;MainClassme;Displaydis;ListmainList;String[]mainString={