import java.awt.*; import java.awt.image.*; import java.applet.Applet; public class k extends Applet implements Runnable{ public final void start() { new Thread(this).start(); } // With a standalone init it doesn't work on MAC :( // With init you can use system.currentTimeMillis() // but it is smaller to use thread.sleep if you need // Thread class anyway public final void run() { final BufferedImage screen = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB); final Graphics g = screen.getGraphics(); // long t_; int counter=0; while(true){ // t_=System.currentTimeMillis(); g.setColor(new Color(0,0,0)); g.fillRect(0,0,800,600); g.setColor(new Color(255,255,255)); g.drawString(""+(counter++), 300,300); // while(System.currentTimeMillis()-t_ < 60){} try{ Thread.sleep(60); }catch(Exception e){} getGraphics().drawImage(screen,0,0,this); } } }