Swing timers question?
okay, so i have a GUI made using swing, and ever 5 seconds or so, i need to update part of the gui from a url. (output.setPage(url))
so i have this running in a timer, the problem is, every time it goes to update, it makes my GUI hang. is there another way to do this that wont make it hang?
Hang sense it's freeze is it?
Seems to me you've done all in UI thread. Actually you must done UI handle in one thread and backend process in another thread(s).
As Eranga states above, the Timer is not the problem. Rather the problem is likely htat your getting the url info on the main Swing thread or EDT (for Event Dispatch Thread). The solution will likely be to keep your Swing Timer, but have it create a SwingWorker object that gets the page in a background thread and then it can update your GUI on the EDT once the information has been obtained. Look up "Concurrency in Swing" for more information on this: Concurrency in Swing
Originally Posted by intel i7
Yep, that's the terminology "Concurrency in Swing". I hope OP not confused with that.
Cross-post: java - Scheduled tasks (Timers) in Swing - Stack Overflow
OP: thanks for having us waste our time answering a question that was already answered in a cross-post, and thus ignoring our answers. If you have any consideration for us and others in the other forum, you will next time notify us in advance if you made any cross-posts and provide links to them. If you don't think that this (our free time) is important, than I'd prefer you not post again in this forum.
Well said Fubarable. I really hate cross-posting.