www.pudn.com > newminesrc.zip > TimeThread.java, change:2002-07-10,size:1383b


//package mine; 
 
import javax.swing.*; 
 
public class TimeThread extends Thread  
{ 
  int numOfSecond = 0; 
  JLabel timeLabel; 
  MainFrame theFrame; 
 
  public TimeThread(MainFrame theFrame) 
  { 
    this.timeLabel = theFrame.jLabelTime; 
    this.theFrame = theFrame; 
     
  } 
  public void run() 
  { 
    numOfSecond = 0; 
    outer: 
    while(true) 
    { 
      if(theFrame.isRestart) 
      { 
        try 
        { 
          Thread.sleep(1000); 
          numOfSecond++; 
          if(numOfSecond < 10) 
            timeLabel.setText("000"+numOfSecond); 
          else 
            if(numOfSecond < 100) 
              timeLabel.setText("00"+numOfSecond); 
            else 
              if(numOfSecond < 1000) 
                timeLabel.setText("0"+numOfSecond); 
                  if(numOfSecond == 9999) 
                    break; 
               
        } 
        catch(InterruptedException e) 
        { 
          JOptionPane.showMessageDialog(null,"InterruptedException occured here: " + e); 
        } 
      } 
      else  
      {/* 
        if(theFrame.sumOfNotMine==0) 
        { 
          JOptionPane.showMessageDialog(null,"You WinŁĄŁĄŁĄ"); 
          break outer; 
        } 
        else 
        { 
          JOptionPane.showMessageDialog(null,"You LoseŁĄŁĄŁĄ"); 
          break outer; 
        }*/ 
        break; 
      } 
    } 
  } 
}