title: Progress Bar Java
body: <p>I am using JProgressBar to show progress. But, How to show the progressBar as loading from 0 to 100? I got the code from internet and its working except the progressBar is not loading. </p>
  
  <p>code</p>
  
  <pre><code>progressFrame = new JFrame(); // frame to display progress bar
  progressBar = new JProgressBar(0,100);
  progressBar.setValue(0);
  progressBar.setStringPainted(true);
  progressFrame.add(progressBar);
  
  new SwingWorker&lt;Void,Void&gt;()
      {
          protected Void doInBackground() throws SQLException, ClassNotFoundException
          {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              progressBar.setValue(0);
              frame.setEnabled(false); // frame = main frame
  
              //tableclass creates a JTable with data from database
              tableclass = new TheDatabaseTable(deptName);//it takes time to create
              progressBar.setValue(50);
              frame.getContentPane().removeAll();
              frame.setContentPane(tableclass);
  
              frame.validate();
              frame.repaint();
  
              progressBar.setValue(100);
              //progressFrame.dispose();
              return null;
          }; 
          protected void done()
          {
              //progressFrame.setVisible(false);
              frame.setVisible(true);
              progressFrame.dispose();
              frame.setEnabled(true);
          }
  
      }.execute();
  </code></pre>
  
  <p>I would appreciate if anyone edit the above code to work. Thank you.</p>