title: How do I make my progress bar run when the "START" button is clicked?
body: <p>I am currently trying to insert a progress bar into my java gui. However, when I click on the "START" button, the progress bar does not run. All the different batch files running in the cmd has to finish then the progress bar runs. But what's the point? I want it to run when the "START" button is pressed and when all the different batch files running in the cmd ends, the progress bar stops too.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>JLabel ProgressBar = new JLabel("Progress Bar: ");
  ProgressBar.setFont(new Font("Arial", Font.BOLD, 12));
  ProgressBar.setBounds(100, 285, 180, 53);
  contentPane.add(ProgressBar);
  final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
  aJProgressBar.setBounds(185,305,184,15);
  contentPane.add(aJProgressBar);
  
  //when start button is selected
  btnStart.addActionListener(new ActionListener()
  {
      public void actionPerformed(ActionEvent args)
      {
          //the process starts
          JStartTimeTextField.setText(dateFormat.format(date));
  
          //the progress bar should show it running (by right)
          aJProgressBar.setIndeterminate(true);
  
          try 
          {
              //create new process    
              String command = "cmd /c start /wait" +DetectDrive+"\\starting.bat";
  
              //run process
              Process p = Runtime.getRuntime().exec(command);
  
              //cause this process to stop until process p is terminated
              p.waitFor();
          } 
          catch (IOException | InterruptedException e1)
          {
              e1.printStackTrace();
          }
  
          ......
  
          Date newDate = new Date();
          JStartTimeTextField.setText(dateFormat.format(newDate));
  
          //the progress bar should stop running (by right)
          //aJProgressBar.setIndeterminate(false);
      }
  });
  </code></pre>
  
  <p>So by right... The startTime should show and the progress bar should be running when the "START" button is clicked. However, only when all the batch files in the cmd finishes running then startTime will show. </p>
  
  <p>But for now, the Progress Bar is my priority. How can I make it that when the "START" button is clicked, the progress bar runs and when all finish, then the progress bar stops?</p>
  
  <p>Any help given will be greatly appreciated!</p>