Could anybody pls pls tell me what is the problem with my following code which is a simple clock(no compile error but doesnt show the time)-
import java.util.*; import java.text.DateFormat; import java.awt.*; import java.awt.geom.*; public class Clock extends Frame implements Runnable {
public void run() { Thread myThread = Thread.currentThread(); while (myThread !=null) { repaint(); try { Thread.sleep(1000); } catch (InterruptedException e){
} } } 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); } //public void update(Graphics g) //{ paint(g) ; }
[how to use repaint method in java console programe(not in applet).when to use repaint and when to use update method and why. could u pls write me a prorgame which has a button that draw something upon being pressed on the frame or just give hints how to do it]