Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Text in textfields not showing up immediately  RSS feed

 
Melanie Fitzgerald
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have several textfields in which I want to set the text. I then I need to do some animation. My problem is that the text doesn't show up in the textfields until the animation has completed. Here is a simplified version of my code:
t1.setText("blah");
t2.setText("blah");
t3.setText("blah");
drawAnimation();
*******************************
drawAnimation () {
....
for (int i = 0; i < interval; i++) {
Thread.sleep(100);
......
// do drawing stuff
}
}
I don�t know if this helps, but what I�m drawing is an arrow which grows about 10 pixels every .1 seconds (why I need the sleep).
I've tried subclassing textfield so that setText() calls the textfields�s paint method right away but this still won't force the text to show up until after the animation is completed. I've also tried subclassing Thread and putting all of the animation in the run method with no luck. Any help would really be appreciated!!
Thanks!
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Melanie,
You might try and call:
t1.update()
immediately after setting the text fro component t1.
Regards,
Manfred.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!