• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextField does not refresh

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic