//this is unaltered, straight from: //http://java.sun.com/docs/books/tutorial/essential/threads/clock.html //Implementing the Runnable Interface //getting error: //java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup) //tried searching for solution, but they all talk about setting permisions for Applet access, but this doesn't use I/O //am confused about that... //have used Date class w/no problems prevously, dont' know... package clock; import java.awt.Graphics; import java.util.*; import java.text.DateFormat; import java.applet.Applet; public class Clock extends Applet implements Runnable { private Thread clockThread = null; public void start() { if (clockThread == null) { clockThread = new Thread(this, "Clock"); clockThread.start(); } } public void run() { Thread myThread = Thread.currentThread(); while (clockThread == myThread) { repaint(); try { Thread.sleep(1000); } catch (InterruptedException e) { //the VM doesn’t want us to sleep anymore, //so get back to work } } } public void paint(Graphics g) { //get the time and convert it to a date Calendar cal = Calendar.getInstance(); Date date = cal.getTime(); //format it and display it DateFormat dateFormatter = DateFormat.getTimeInstance(); g.drawString(dateFormatter.format(date), 5, 10); } //overrides Applet’s stop method, not Thread’s public void stop() { clockThread = null; } }