aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Updating JList Components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Updating JList Components" Watch "Updating JList Components" New topic
Author

Updating JList Components

A. Wolf
Ranch Hand

Joined: Sep 28, 2003
Posts: 57
Hi, I have a JProgressBar on a JPanel as a JList component. the JList component is supposed to make the JProgressbar advance, but it doesn't happen. I can't seem to find where I should listen for changes or update. here is an example of this. When making a main method for ManagerIndex that creates a JFrame with the components it gets updated without any problems.


A. Wolf
Ranch Hand

Joined: Sep 28, 2003
Posts: 57
why doesn't anyone reply? did I give too much non-important info or too little?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Your renderer is returning a new component every time... renderers aren't used that way. You should only create 1 instance of the actual component and use set... methods to set the values for each of the cells inside the getListCellRendererComponent().


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
A. Wolf
Ranch Hand

Joined: Sep 28, 2003
Posts: 57
thanks so far. I fixed it so my LCRenderer extends JPanel and returns 'this' like the example in the docs, and ManagerIndex class has been removed.
one thing though, it sort of wants to update, but only while I am resizing the window, otherwise the Jprogressbar stays the same. What do I need to do to fix this? I mean what do I have to update after the ProgressBar's value has been changed?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You're updating the progress bar outside the event thread... you'll either need to use a Timer or SwingUtilities.invokeLater() to update the progress bar in the event thread so it repaints correctly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating JList Components