问一个简单的问题,有关进度条,不知道怎么用
怎么由这个进度条切换到一个form,不会用,麻烦给讲解一下
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class xpsroll extends Canvas
implements Runnable,CommandListener
{
int x = 51;
int y = 51;
int w2 =1 ;
int r = 0;
Command st = new Command("Began",Command.OK,1);
Command op = new Command("Stop",Command.STOP,1);
public xpsroll()
{
addCommand(st);
setCommandListener(this);
}
public void paint(Graphics g)
{
clear(g);
g.setColor(0,0,0);
g.drawRect(50,50,102,12);
drawRt2(g,x,y,w2,10);
}
public void clear(Graphics m)
{
m.setColor(255,255,255);
m.fillRect(0,0,getHeight(),getWidth());
}
public void drawRt2(Graphics n,int x2,int y2,int w,int h)
{
n.setColor(0,0,255);
n.drawRect(x2,y2,w,h);
n.fillRect(x2,y2,w,h);
}
boolean con;
public void commandAction(Command o,Displayable s)
{
if(o == st)
{
con = true;
removeCommand(st);
addCommand(op);
Thread t = new Thread(this);
t.start();
}else if(o == op)
{
con = false;
}
}
int d = 50;
public void run()
{
long a = 0;
long b = 0;
long c = 0;
while(con)
{
a = System.currentTimeMillis();
w2 += 1;
r ++;
if(r > 100)
{
r = 0;
}else if(w2 == 100)
{
con = false;
}
b = System.currentTimeMillis();
c = b - a;
if(c < d)
{
try
{
Thread.sleep(d - c);
}catch(Exception e){}
}
repaint();
}
}
}