关于ProgressMonitor的使用问题,解决马上给分!!

Jamesczh 2005-03-31 11:51:00
我做了一个很简单的测试程序,目的是我在一个JFrame的按钮的单击事件里,弹出一个进度等待的对话框,下面是我在按钮的单击事件监听器里加的代码:
ProgressMonitor pMonitor=new ProgressMonitor(m_frame,"Import order","",0,100);
pMonitor.setNote("process...");
pMonitor.setMillisToDecideToPopup(0);
pMonitor.setMillisToPopup(1000);
pMonitor.setProgress(0);
for (int i=0;i<100;i++){
pMonitor.setProgress(i);
}
但现在我无法弹出进度等待对话框,希望哪位朋友大帮帮忙!谢谢!
...全文
216 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jianghuxing 2005-03-31
  • 打赏
  • 举报
回复
应当就是那个问题
Hodex 2005-03-31
  • 打赏
  • 举报
回复
ProgressMonitor pMonitor=new ProgressMonitor(jf,"Import order","",0,100);
pMonitor.setNote("process...");
pMonitor.setMillisToDecideToPopup(0);
pMonitor.setMillisToPopup(1100);
pMonitor.setProgress(0);
for (int i=0;i<101;i++){//长度是0-100,所以...^^
pMonitor.setProgress(i);
try{
Thread.currentThread().sleep(100);//太快了,给它慢下来,见下面解释
}catch(Exception e1){
System.out.println ("ft");
}
}

A class to monitor the progress of some operation. If it looks like the operation will take a while, a progress dialog will be popped up. When the ProgressMonitor is created it is given a numeric range and a descriptive string. As the operation progresses, call the setProgress method to indicate how far along the [min,max] range the operation is. Initially, there is no ProgressDialog. After the first millisToDecideToPopup milliseconds (default 500) the progress monitor will predict how long the operation will take. If it is longer than millisToPopup (default 2000, 2 seconds) a ProgressDialog will be popped up.

From time to time, when the Dialog box is visible, the progress bar will be updated when setProgress is called. setProgress won't always update the progress bar, it will only be done if the amount of progress is visibly significant.

62,614

社区成员

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

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