import javax.microedition.lcdui.*;
Pp ybFv4 import javax.microedition.midlet.*;
, jzo_w public class DrawCanvas extends MIDlet implements CommandListener {
3x4Yc}o private Command exitCommand;
HR bc(|D1| private HCanvas sg;
#{br S5 public DrawCanvas() {
#0FDK4y exitCommand = new Command("Exit", Command.EXIT, 1);
G_ernhX) sg = new HCanvas();
bEcU<}0" sg.addCommand(exitCommand);
FcKQm]1 sg.setCommandListener(this);
M&h2sxx # Display.getDisplay(this).setCurrent(sg);
WwHK97bx ;GxB9@Fm[ }
]JZKZY7x protected void startApp(){
[6hDY.A^ }
n1j3P9=T protected void pauseApp() {
Ax];d|{T }
7ZOj'|"[f protected void destroyApp(boolean arg0){
uqIPj1yi; }
Xh3Rt@cv public void commandAction(Command c, Displayable d) {
s1LJ:{w if (c == exitCommand) {
MD{tfG destroyApp(false);
nu{YGk notifyDestroyed();
*!bv{~{ZB }
jshwo!`9N }
t{oZrcs= }
sr[)G|\z- class HCanvas extends Canvas implements Runnable{
<>)V`M [}<z>Ok private String str=new String("PRESS 5");
>IB+h] private int[] ak={0,0,0,0,0,0,0,1,2,3,3,2,1,0,0,0,0,0,0,0};
6pCAs[{n boolean kaishi=true;
q+p iVx private int k=6;
,tyAd-I/ >w0x%?5^6% public HCanvas (){
(Y&jT1wu(M new Thread(this).start();
~hH;:iX7G }
EYB8^ g:[ {`(/rdCWc protected void paint(Graphics g){
->ECdP=c g.setColor(0x00ffffff);
=n=:4@ g.fillRect(0,0,getWidth(),getHeight());
au]K@* g.setColor(0x00000000);
Nl;M%)o for(int i=0;i< str.length();i++){
R F::^w g.drawString(str.substring(i,i+1),20+i*7,10-ak[k-i],0);
Ud[OW|i g.drawString(str.substring(i,i+1),21+i*7,11-ak[k-i],0);//加重字体7是字体宽度
*#T8_I_Kg }
M 9cg8$ }
/Z*c#:m=E& public void run(){
7 h`1z while(kaishi){
`|n`8RU try {
x(dOk7a repaint(); //再描绘
|ip)rlU Thread.sleep(70); //等待一定时间
rec=H1q k++;
vwR5-~a if(k>(ak.length-1)) k=6;
ge>AB#YL }
92ceN3% N catch(InterruptedException e){}
\|yHDBNw }
j=o,C3=cB }
5P$zm't+ }
tMq*uUdR, #hHft;bg ~L2sO[:ax
查看本文来源