update frames

hi i have created a gui, it has all the jbuttons and panels and frames added in, i have also added in time, could you tell me how i can refresh the frame every 1 second for example, so the time can change all the time
[224 byte] By [javaking312a] at [2007-11-26 13:10:04]
# 1

You've got a couple of different topics in there.

1. To perform a task say every second or so use a timer. I'd recommend doing this in a thread but there are other options as well.

2. Call the container's repaint method, or if you're only concerned about the time element just change the text every time the timer kicks off.

Cheers,

PS

puckstopper31a at 2007-7-7 17:23:44 > top of Java-index,Java Essentials,Java Programming...
# 2
iim really stuck now, have no idea how to create timers, been trying for last hr or so. how would i do this?
javaking312a at 2007-7-7 17:23:44 > top of Java-index,Java Essentials,Java Programming...
# 3
See the javadoc: http://java.sun.com/javase/6/docs/api/javax/management/timer/Timer.htmlKaj
kajbja at 2007-7-7 17:23:44 > top of Java-index,Java Essentials,Java Programming...
# 4
See top part of http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Timer.html for a simple example on how to use a timer for a swing component (update the label displaying the time inside the actionPerformed(...) method).Jukka
duckbilla at 2007-7-7 17:23:44 > top of Java-index,Java Essentials,Java Programming...
# 5
@Op. Ignore my link. I posted a Link to the wrong Timer. You should use either java.util.Timer or javax.swing.TimerKaj
kajbja at 2007-7-7 17:23:44 > top of Java-index,Java Essentials,Java Programming...