• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Force ListCellRenderer to update GUI

Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a JList which shows a list of files. I can programmatically grab the selected files and loop through each file - performing operations on it.
What I want to do is change the background of a file once it has been processed to show the status of the file (Green = OK, Red = Fail).
I am storing the index of the files in 2 ArrayLists - one for the good files and one for the bad files.
I have created the ListCellRenderer which will set the appropriate background depending on whether a file is in one of the ArrayLists or not.
The problem is that the custom ListCellRenderer only updates the JList AFTER all files have been processed. I want the JList to be updated after each individual file has been processed. Is this possible?
I have added Thread.yield() and Thread.sleep(5000) and JList.repaint() in the loop that processes each file - but these do not work.
Can anyone help me?
Many thanks,
PS Here is the code that loop thro' each file :

Here is the getListCellRendererComponent method of my ListCellRenderer :
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for(int i = 0; i < userListModel.size(); i++) {
userListModel.setElementAt(userListModel.getElementAt(i), i);

    Bookmark Topic Watch Topic
  • New Topic