Minggu, 16 Januari 2011

Applications Java Timer

This timer application I created using java, and if you are interested to try it, please download the application here. I also include the source code below :
 
public class waktu extends javax.swing.JFrame implements Runnable {
Thread th;
int ms = 0;
int s = 0;
int m = 0;
private void bstartActionPerformed(java.awt.event.ActionEvent evt) {                                      
        th = new Thread(this);
        th.start();
        bstart.setText("stop");
    }                                     
public void run(){
    try{
      while(true){
          ms++;
          th.sleep(17);
          if(ms >= 60){
              ms=0;
              s++;
          }
          if(s >= 60){
              s = 0;
              m++;
          }
          if(m >= 60){

          }
          String waktu;
          waktu = m + ":" + s + ":" + ms;
          labelwaktu.setText(waktu);
      }
    }
    catch(Exception e){

    }
}

Tidak ada komentar:

Powered By Blogger