Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

validate vs. revalidate(Threaded Swing Applet)

 
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,
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic