title: how to stop a timer with 'if'
body: <p>hi guys i am new to java... :(
  i just want my button(start) to start a timer but i want to stop the timer automatically with 'if' so for example... when a user enters a time and the timer get's to the timer it stops... so far my coding is like this...</p>
  
  <pre><code>private void startTimerActionPerformed(java.awt.event.ActionEvent evt) {                                               
  
          javax.swing.Timer tm = new javax.swing.Timer(100, new ActionListener()
          {
              public void actionPerformed (ActionEvent evt) {
                  AddOneActionPerformed(evt);
              }   
          });
  
          tm.start();
  
          int getTM,getM,getTS,getS,Secs,tenSec,Mins,tenMin;
  
          getTM = Integer.parseInt(enterTenMins.getText());
          getM = Integer.parseInt(enterOneMins.getText());
          getTS = Integer.parseInt(enterTenSecs.getText());
          getS = Integer.parseInt(enterOneSecs.getText());
  
          tenMin = Integer.parseInt(tenMins.getText());
          Mins = Integer.parseInt(oneMins.getText());
          tenSec = Integer.parseInt(tenSecs.getText());
          Secs = Integer.parseInt(oneSecs.getText());
      }                                    
  </code></pre>
  
  <p>and <code>AddOneActionPerformed(evt)</code> is</p>
  
  <pre><code>private void AddOneActionPerformed(java.awt.event.ActionEvent evt) {                                       
          int dd,Secs,tenSec,Mins,tenMin;
  
          tenMin = Integer.parseInt(tenMins.getText());
          Mins = Integer.parseInt(oneMins.getText());
          tenSec = Integer.parseInt(tenSecs.getText());
          Secs = Integer.parseInt(oneSecs.getText());
          dd= Integer.parseInt(digitValue.getText());
          dd= dd+1;
  
  
          if (dd==10)
              dd = 0;
  
          if (Secs == 10)
              Secs = 0;
  
          if (dd==0)
              Secs=Secs +1;
  
          if (tenSec&gt;=6)
              tenSec = 0;
  
          if (Secs==10)
              tenSec=tenSec +1;
  
          if (Mins==10)
              Mins = 0;
  
          if (tenSec==6)
              Mins=Mins+1;
  
          if (tenMin&gt;=6)
              tenMin=0;
  
          if (Mins==10)
              tenMin=tenMin+1;
  
          String ss = Integer.toString(dd);
          digitValue.setText(ss);
  
          String ff = Integer.toString(Secs);
          oneSecs.setText(ff);
  
          String gg = Integer.toString(tenSec);
          tenSecs.setText(gg);
  
          String hh = Integer.toString(Mins);
          oneMins.setText(hh);
  
          String jj = Integer.toString(tenMin);
          tenMins.setText(jj);
  
          showDigitActionPerformed(evt);
          showOneSecsActionPerformed(evt);
          showTenSecsActionPerformed(evt);
          showOneMinsActionPerformed(evt);
          showTenMinsActionPerformed(evt);
  
      }
  </code></pre>