Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Force ListCellRenderer to update GUI

 
Fintan Conway
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • 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,
Fintan
PS Here is the code that loop thro' each file :

Here is the getListCellRendererComponent method of my ListCellRenderer :
 
phil marquet
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for(int i = 0; i < userListModel.size(); i++) {
userListModel.setElementAt(userListModel.getElementAt(i), i);
}

pm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic