Java Swing Refresh
Posted on 2004-11-07
I am creating an Air Traffic Control simulation. It is going to update an image in the main window every 3 seconds (to account for the radar swinging around - it takes 3 seconds in this simulation). I have everything accounted for, but I am wondering the best way to do something. What I need to do is have the system constantly updating the main image (i.e. repainting the screen) every 3 seconds, but also allow the user to be doing something in the meantime (i.e. clicking on stuff, etc...). I would prefer to stay away from threads, if possible, because that adds an extra layer of complexity that I don't know if I really want to deal with. Unfortunately, I think that that is perhaps the only way.
Currently, I have a refresh() method that does everything that needs to be done as far as drawing the screen goes. I just need it to call the refresh method every 3 seconds, while still allowing the user to interact with the system.
Thanks in advance,