怎样做个进程条?

bjmylihui 2003-09-29 04:54:33
如上
...全文
59 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wbq1099 2003-10-14
  • 打赏
  • 举报
回复
画两个矩形,一个长的固定不变,另外一个由短变长,即可模拟一个进度条。
疯狂低调 2003-10-14
  • 打赏
  • 举报
回复
我靠,J2ME中的进度条,只有 Gauge,要么自己画吧
chaojinn 2003-10-14
  • 打赏
  • 举报
回复
JProgressBar
bjmylihui 2003-10-14
  • 打赏
  • 举报
回复
进程条是做出来了,但是要是需要多次显示他,在每个要显示进程条的类里,编写这么一大堆重复代码,这么各做法不太实际。我想把它做成一个类,每次要用的时候只要生成该类的对象就可以了。请问怎么改,我试着改了一下,可显示的结果不对。
public class test extends MIDlet
{
Procedure enter;
/*Procedure是做好的进程条类,多线程的,其中含有变量form,为进程调界面
。。。。。
public test()
{
enter=new Procedure();
}
public void startApp()
{
display.setCurrent(enter.form);
enter.start();

}
}
可结果就是不对。
zkjbeyond 2003-10-14
  • 打赏
  • 举报
回复
<!-- web进度条 sunmingdong(原作)
源代码如下,很容易读,有问题请email: sunmingdong@371.net
//-->

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
var myTime=0
function counter(){
myTime++
per.innerHTML="<font size=2 color=darkblue>  "+myTime+"%</font>"
if (myTime<100)
setTimeout("counter()",40);
else{
window.open("http://www.sina.com.cn",null,"fullscreen=no,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no")
}
}
function window_onload() {
counter()
}

//-->
</SCRIPT>
</HEAD>
<BODY LANGUAGE=javascript onload="return window_onload()">
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>

<table border="0" cellpadding="0" cellspacing="0" width="50%" align=center>
<tr>
<td width="51%" noWrap>
<p align="right"><FONT face=宋体 color=navy
size=2>正在加载:</FONT></p> </td>
<td width="4%" bordercolor="#000000">
<marquee align="middle" direction="right" scrolldelay="1" bgcolor="gainsboro" scrollamount="2" style="BORDER-RIGHT: black 1px outset; BORDER-TOP: black 1px outset; FONT-SIZE: xx-small; BORDER-LEFT: black 1px outset; WIDTH: 133px; COLOR: #000080; BORDER-BOTTOM: black 1px outset; HEIGHT: 13px"
behavior="slide"
>███████████████████████████████████████████████████████████████████████████████</marquee>
</td><td width="45%" align=left><div id=per></div></td>
</tr>
</table>


</BODY>
</HTML>
bjmylihui 2003-10-14
  • 打赏
  • 举报
回复
to bruce_wang j2me里没有swing
我找个例子改了改,
public class test extends MIDlet implements Runnable,CommandListener
{



//与进程条有关的变量
private long trival=1000;
private Alert finish;
private Gauge gauges;
private Form form,after;
private Thread thread=null;

private Command cmdExit;
public test()
{
display = Display.getDisplay(this);
form=new Form("连接中");
after=new MainForm();//MainForm是自己编写的,在进程条显示后显示
thread=new Thread(this);
cmdExit=new Command("取消",Command.EXIT,1);

gauges=new Gauge("请等待",false,20,0);
finish=new Alert(""," 连接成功!",null,AlertType.INFO);
//finish.setTimeout(Alert.FOREVER);
form.append(gauges);
form.addCommand(cmdExit);

form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
thread.start();

}

public void run()
{

while(true)
{
int value=gauges.getValue();

try
{
Thread.sleep(500);
}
catch(Exception ex){}

if(value<gauges.getMaxValue())
{
gauges.setValue(value+1);

}
else if(value==gauges.getMaxValue())
{
isPause=true;

display.setCurrent(finish,after);

break;
}


}

}
public void pauseApp() {
}

public void destroyApp(boolean unconditional)
{
}

public void commandAction(Command c,Displayable d)
{
if(c==cmdExit)
{
thread=null;
destroyApp(true);
notifyDestroyed();


}
}

}
bruce_wang 2003-10-01
  • 打赏
  • 举报
回复
swing就有进度条啊,你们不知道么?
JProgessBar

有3个构造函数:
JProgessBar()
JProgessBar(int min, int max)
JProgessBar(int orient, int min, int max)

可以配合计时器一起使用,具体可以找一下swing方面的书。
MrYoucheng 2003-10-01
  • 打赏
  • 举报
回复
如果你使用canvas 你也可以自己话一个
首先创建一个线程 让他不停的repaint
在canvas的paint方法中调用drarBar(g)

void drawBar(Graphics g)
{
g.setColor(122,21,12);
for(int i=0;i<restTime;i++)
{
g.drawLine(i,0,i,20);
}
}

这只是一个示意
天天轻松 2003-09-29
  • 打赏
  • 举报
回复
用一个Gauge,然后用一个线程不断刷新Gauge的值。

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧