我用netbeans写了一个桌面应用程序,各个控件是直接拖拽过去的,进度条的maximum也设置大小了,也设置了进度条的可见属性,最后他自动生成了一些代码,有些看不懂,就自己用Timer和TimerTask写了一个定时改变JProgressBar的value属性的值,来实现进度条的动态表示,但是运行程序后进度条就是显示不出来,到最后程序要运行完的时候才突然显示出进度条,怎么让进度条动态显示呀,就像netbeans自带的一个MarsRoverViewer例子中的那样显示,用过netbeans的高手给点指导意见吧!或是给个有用的链接也可以,在网上找啦半天都没有找到一个能用的,谢谢!!!下面是我写的Timer和TimerTask的代码,高手给点建议!!!!!!!!!!!!
 public class TimerUse {
        private java.util.Timer timer1 = null;
        public TimerUse() {
            timer1 = new java.util.Timer(true);
        }
        private TimerTask task = new TimerTask() {
            public void run() {
                try {
                    BufferedReader br = new BufferedReader(new FileReader(file.getParent() + "/rowNum.txt"));
                    String data = null;
                    String lastTimeData = "a";
                    while ((data = br.readLine())!= null && !data.equals("")&& !data.equals(lastTimeData)) {
                       lastTimeData = data;
                        processingValue = new Integer(data.trim());
                        System.out.println("processingValue" + processingValue);
                        progressBar.setValue(processingValue);
                        progressBar.setVisible(true);
                       
                    }
//                     if (processingValue == jProgressBarMaximum) {
//                            task.cancel();
//                        }
                } catch (FileNotFoundException e) {
                    System.out.println("can not find the file");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        };        public void start(int delay, int internal) {
            timer1.schedule(task, delay * 10, internal * 10);
        }
    }