• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField does not refresh  RSS feed

 
Mike London
Ranch Hand
Posts: 1340
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTextField in a loop where I'm updating
directory names. However, the method I'm using inside the loop, setText(), doesn't update the JTextField until the last directory name element.
Any ideas how I can get the JTextField to update with each file name in the loop as it's coded to do?
Here's the code statement that is coded inside the for loop. It should, by my way of thinking, update the JTextField in each loop iteration.
=================================================
this.jTextField_Status.setText("Now searching:" + currentDirFileListi].toString());
==================================================
Look forward to anyone's input.
Maybe this needs to be a separate thread? I also have a System.out.println in the same loop that prints correctly for each directory element.
Thanks.
Mike.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your instinct that this needs to be threaded is correct. The Swing objects will not get repainted until the completion of the loop if they are in the same thread as the loop.
 
Mike London
Ranch Hand
Posts: 1340
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!