membuat stopwatch menggunakan java (netbeans)

nah.,, kali ini saya akan mencoba share membuat stopwatch dengan java desktop aplication yaitu tepatnya menggunakan netbeans...
langsung ajah sorce codenya :


public class FormUtama extends javax.swing.JFrame implements Runnable {
     Thread th;
     int ms = 0;
     int s = 0;
     int m = 0;
     public FormUtama() {
           initComponents();
     }
     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){


    }
}
private void bStartActionPerformed(java.awt.event.ActionEvent evt) {
     th = new Thread(this);
     th.start();
     bStart.setText("Stop");
}


untuk hasil Running dari programnya seperti ini : 



semoga bermanfaat,,,,,,,
^_^


1 komentar:

Blogger mengatakan...

Your Affiliate Profit Machine is ready -

And getting it running is as simple as 1-2-3!

Here is how it all works...

STEP 1. Choose affiliate products you intend to promote
STEP 2. Add push button traffic (this ONLY takes 2 minutes)
STEP 3. Watch the affiliate system explode your list and sell your affiliate products for you!

Are you ready to make money automatically??

Click here to activate the system

Posting Komentar