Guest User

Untitled

a guest
Aug 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.  
  2. package appletthread;
  3.  
  4. import java.applet.Applet;
  5. import java.awt.Graphics;
  6.  
  7. public class AppletThread
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.     }
  12. }
  13.  
  14. class Chrono extends Applet implements Runnable
  15. {
  16.     int heures;
  17.     int minutes;
  18.     int secondes;
  19.    
  20.     public void init()
  21.     {
  22.         this.heures = 0;
  23.         this.minutes = 0;
  24.         this.secondes = 0;
  25.        
  26.         Thread t = new Thread(this);
  27.         t.start();
  28.     }
  29.  
  30.     @Override
  31.     public void run()
  32.     {  
  33.         this.secondes++;
  34.        
  35.         if (this.secondes == 59)
  36.         {
  37.             this.minutes++;
  38.             this.secondes = 0;
  39.         }
  40.        
  41.         if (this.minutes == 59)
  42.         {
  43.             this.heures++;
  44.             this.minutes = 0;
  45.         }
  46.        
  47.         //throw new UnsupportedOperationException("Not supported yet.");
  48.     }
  49.    
  50.     public void paint(Graphics g)
  51.     {
  52.         g.drawString(this.heures + ":" + this.minutes + ":" + this.secondes, WIDTH, WIDTH);
  53.     }
  54. }
Add Comment
Please, Sign In to add comment