分类：电脑/网络-程序设计-JAVA相关
问题：JProgressBar的问题为什么设置setValue它不是自 
为什么设置setValue它不是自己跟着变呢，总在全部完成的时候一下子变成了100%，郁闷死我了
回答：因为需要一个线程跟踪立即重绘进度条区域才可以举了个小例子，刚写的，单击窗体就有0－100的动态显示import  t.BorderLayout;import  t.Tool;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JProgressBar;public class Test2 extends JFrame {  private static final long serialVersionUID = 1L;  private JPanel jContentPane = null;  private JProgressBar jProgressBar = null;  public Test2() {    super();    initialize();  }  private void initialize() {     tSize(300, 200);     tIconImage( tDefaultToolkit().getImage("C:/Documents and Settings/pig0301/My Documents/My Pictures/ g"));     tContentPane(getJContentPane());     tTitle("JFrame");  }  private JPanel getJContentPane() {    if (jContentPane == null) {      jContentPane = new JPanel();       tLayout(new BorderLayout());       d(getJProgressBar(), BorderLayout.CENTER);    }    return jContentPane;  }  private JProgressBar getJProgressBar() {    if (jProgressBar == null) {      jProgressBar = new JProgressBar();       tMinimum(0);       tMaximum(100);       dMouseListener(new  t.event.MouseAdapter() {        public void mouseClicked( t.event.MouseEvent e) {          ProgressThread p = new ProgressThread();          for(int i = 0; i < 101; i++){            try{             eep(50);             tValue(i);            }catch(Exception ex){}          }                    }      });    }    return jProgressBar;  }    class ProgressThread extends Thread{        private int value = 0;        public void setValue(int i){      value = i;      run();    }        public void run(){       tValue(value);       intImmediately( tX(),  tY(),  tWidth(),  tHeight());    }  }}