Results 1 to 5 of 5
Thread: setText() problem
- 04-26-2010, 10:50 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
setText() problem
Hi all!
I have a problem - my Java program doesn't do what I want to. He doesn't display "downloading effect" - he waits 5 seconds and then sets text: 100% downloaded. Please help!
for(int i=0;i<101;i++)
{
t1.setText(i + "% downloaded...");
try {Thread.currentThread().sleep(50);}
catch (InterruptedException a) {
a.printStackTrace();
}}
-
If you call Thread.sleep in the main GUI thread (the EDT), you in effect put the whole app to sleep. If this is a Swing app, you're far better off using a Swing Timer.
- 04-26-2010, 10:57 PM #3
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
OK
can you change my code that it works?
thanks
-
It would be much better if you read the tutorial and did it yourself: How to Use Swing Timers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features) as you would learn much more in the process. Please feel free to come on back if it doesn't work, and much luck!
- 04-27-2010, 05:29 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
setText in JTextArea
By hero in forum AWT / SwingReplies: 1Last Post: 10-12-2009, 09:38 PM -
[SOLVED] [newbie] AbstractButton.setText() not setting text within JButton
By jon80 in forum New To JavaReplies: 3Last Post: 05-25-2009, 03:33 AM -
setText() problem
By jls7168 in forum New To JavaReplies: 2Last Post: 02-20-2009, 10:34 PM -
[SOLVED] new2java- gettext settext
By obdi in forum New To JavaReplies: 4Last Post: 07-21-2008, 09:28 AM -
setText in event
By sniezna.stopa in forum SWT / JFaceReplies: 0Last Post: 06-20-2008, 02:56 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks