Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validate vs. revalidate(Threaded Swing Applet)

 
Sue Fish
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't realize I had an error until I ran this on an SGI. I have a Threaded Swing Applet that launches a jpanel containing some JTextFields. When entering random text in the textfield the browser (JVM?) hangs. I narrowed it down to my run loop in my applet and changed my code and it seems to have fixed the problem - I'm just not sure why!
OLD CODE:
while (!appletDone) {
validate();
Thread.sleep(500)
... some other checks jpanel.repaint()
}
NEW CODE:
validate();
while (!appletDone) {
theDisplay.revalidate(); // main JPanel
Thread.sleep(500);
...
}
I am pretty sure this has to do with AWT vs. Swing (and swing not being thread safe) But can't seem to find any good documentation. What is the proper way to manage Swing GUI/repainting & revalidating?
Thanx for any info,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic