学习。
他好象不能控制程序的运行吧,应该是模拟程序的运行进度,也不是真的就那样。只是在程序的线程运行过程中,去访问JProgressBar,更新他的值(大部分用颜色填充),来给你一种进度的感觉。
继续学习。

解决方案 »

  1.   

    这是我看到了的一则代码,
    我用后觉得有控制但是不是很好,大家看看,给些意见!
          m_counter = 0;
          progress1.setValue(m_counter);
          jPanel11.remove(jScrollPane4);
          jPanel11.add(panel1, BorderLayout.CENTER);
          jTabbedPane2.setVisible(true);
          jTabbedPane2.paintAll(jTabbedPane2.getGraphics());
          UpdateThread update = new UpdateThread();
          update.start();
          MyNode node = new MyNode(Schema, BO_name, "bo", level);
          MyModel model = new MyModel(node);
          JTree jTree2 = new JTree(model);
          jScrollPane4.getViewport().add(jTree2, null);
          if (!update.isInterrupted()) {
            update.interrupt();
            update.stop();
          }
          while (m_counter < m_max) {
            progress1.setValue(m_counter);
            jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(),
                                          progress1.getWidth(),
                                          panel1.getHeight() / 7);
            m_counter = m_counter + 2;
            try {
              Thread.sleep(50);
            }
            catch (Exception ex) {
            } 线程
     class UpdateThread
          extends Thread {
        Runnable runme;
        public UpdateThread() {
        }    public void run() {
          m_counter = m_min;
          try {
            while (m_counter <= m_max) {
              progress1.setValue(m_counter);          jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(),
                                            progress1.getWidth(),
                                            panel1.getHeight() / 7);
              m_counter = m_counter + 2;
              try {
                Thread.sleep(500);
              }
              catch (Exception ex) {
              }
            }
          }
          catch (Exception e) {
            while (m_counter < m_max) {
              progress1.setValue(m_counter);
              jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(),
                                            progress1.getWidth(),
                                            panel1.getHeight() / 7);
              m_counter = m_counter + 2;
              try {
                Thread.sleep(50);
              }
              catch (Exception ex) {
              }
            }
            return;
          }
        }
      }
      

  2.   


        你最大值m_max是怎么得到的?
      

  3.   

    刚才,发作地方了。抱歉!我就是因为m_max无法得到,所以没办法控制的。各位有什么想法?谢谢