title: How to update a ProgressBar and stop It when I want?
body: <p>In first, I'm using <strong><em>Eclipse IDE</em></strong>. So my question is: I create a progress bar, but I want to make it load according to the place where the program is. I have a refresh button, and when I click it my entire program update. What I want is a progress bar that accompanying the process of updating and ends when it ends.</p>
  
  <p>Sorry if my English isn't the best, but I'm a young Portuguese developer.</p>
  
  <p><strong><em>my btn code</em></strong></p>
  
  <pre><code>JButton btnActualizar = new JButton("\u21BB");
      btnActualizar.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
  
  
              TxtIpExternoLoja.setText(" ");
              TxtSSIDLoja.setText(" ");
              TxtFirewallLoja.setText(" ");
  
              TxtIpLojaEtho.setText(" ");
              TxtMaskLojaEtho.setText(" ");
              TxtGWLojaEtho.setText(" ");
              TxtDns1LojaEtho.setText(" ");
              TxtDns2LojaEtho.setText(" ");
  
              TxtIpLojaWlan.setText(" ");
              TxtMaskLojaWlan.setText(" ");
              TxtGwLojaWlan.setText(" ");
              TxtDns1LojaWlan.setText(" ");
              TxtDns2LojaWlan.setText(" ");
  
              TxtIpLojaVpn.setText(" ");
              TxtMaskLojaVpn.setText(" ");
              TxtGwLojaVpn.setText(" ");
              TxtDns1LojaVpn.setText(" ");
              TxtDns2LojaVpn.setText(" ");
  
              // DefaultTableModel model = (DefaultTableModel)
              // tablePing.getModel();
              // model.setRowCount(0);
              TxtTime.setText(" ");
  
              i = 0;
              t.start();
              btnActualizar.setEnabled(false);
              update();
  
          }
      });
  </code></pre>
  
  <p><strong><em>my progressbar code:</em></strong></p>
  
  <pre><code>JProgressBar progressBar = new JProgressBar(0, 15);
      GridBagConstraints gbc_progressBar = new GridBagConstraints();
      gbc_progressBar.insets = new Insets(0, 0, 0, 5);
      gbc_progressBar.gridx = 3;
      gbc_progressBar.gridy = 0;
      PanelBotoes.add(progressBar, gbc_progressBar);
      GridBagConstraints gbc_btnImprimir = new GridBagConstraints();
      gbc_btnImprimir.insets = new Insets(0, 0, 0, 5);
      gbc_btnImprimir.gridx = 5;
      gbc_btnImprimir.gridy = 0;
      PanelBotoes.add(btnImprimir, gbc_btnImprimir);
      progressBar.setStringPainted(true);
      progressBar.setValue(0);
  
      t = new Timer(interval, new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
              if (i == 15) {
                  t.stop();
                  btnActualizar.setEnabled(true);
              } else {
                  i++;
                  progressBar.setValue(i);
              }
          }
      });
  </code></pre>