import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
public class JprogessBar extends JFrame implements Runnable{
JProgressBar bar;
static Thread thread;
public JprogessBar(){
bar=new JProgressBar(0,1000);
Container con=getContentPane();
con.add(bar);
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
setLocation((screenSize.width - 250) / 2, (screenSize.height - 250) / 2);
setVisible(true);
}
public static void main(String para[]){
JprogessBar scrollbar=new JprogessBar();
thread=new Thread(scrollbar);
thread.start();
scrollbar.pack();
}
public void run() {
// TODO 自动生成方法存根
int sum=0;
int i=0;
while(true){
if(sum>1000)
break;
sum=sum+50;
bar.setValue(sum);
try {
thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}
}
posted on 2007-07-16 12:45
lcgxc 阅读(293)
评论(0) 编辑 收藏 所属分类:
java