title: Progress Monitor Implementation in Java
body: <p>I want to show the progress of my program process which using progress monitor in java. i've put this code below as progress monitor in my new frame.</p>
  
  <pre><code>package eksim.view;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.JFrame;
  import javax.swing.ProgressMonitor;
  import javax.swing.SwingUtilities;
  import javax.swing.Timer;
  import javax.swing.UIManager;
  
  
  public class ProgBar extends javax.swing.JInternalFrame implements ActionListener {
  
      static ProgressMonitor pbar;
      static int counter = 0;
  
      /**
       * Creates new form ProgBar
       */
      public ProgBar() {
          initComponents();
      }
  
      public void ProgressMonitorExample() {
      super("Progress Monitor Demo");
      setSize(250, 100);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      pbar = new ProgressMonitor(null, "Monitoring Progress",
          "Initializing . . .", 0, 100);
  
      // Fire a timer every once in a while to update the progress.
      Timer timer = new Timer(500, this);
      timer.start();
      setVisible(true);
    }
  
    public static void main(String args[]) {
      UIManager.put("ProgressMonitor.progressText", "This is progress?");
      UIManager.put("OptionPane.cancelButtonText", "Go Away");
      ProgressMonitorExample();
    }
  
    public void actionPerformed(ActionEvent e) {
      // Invoked by the timer every half second. Simply place
      // the progress monitor update on the event queue.
      SwingUtilities.invokeLater(new Update());
    }
  
    class Update implements Runnable {
      public void run() {
        if (pbar.isCanceled()) {
          pbar.close();
          System.exit(1);
        }
        pbar.setProgress(counter);
        pbar.setNote("Operation is " + counter + "% complete");
        counter += 2;
      }
    }
  
  
      /**
       * This method is called from within the constructor to initialize the form.
       * WARNING: Do NOT modify this code. The content of this method is always
       * regenerated by the Form Editor.
       */
      @SuppressWarnings("unchecked")
      // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt;                          
      private void initComponents() {
  
          jProgressBar1 = new javax.swing.JProgressBar();
  
          setClosable(true);
          setIconifiable(true);
          setMaximizable(true);
          setTitle("Progress Monitor");
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addGap(31, 31, 31)
                  .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 335, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addContainerGap(28, Short.MAX_VALUE))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                  .addContainerGap(66, Short.MAX_VALUE)
                  .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addGap(48, 48, 48))
          );
  
          pack();
      }// &lt;/editor-fold&gt;                        
      // Variables declaration - do not modify                     
      private javax.swing.JProgressBar jProgressBar1;
      // End of variables declaration                   
  }
  </code></pre>
  
  <p>But, it didn't show anything as it works. Could anyone help me? Thanks</p>