I have a JList where each item in the list is rendered by a
ListCellRenderer. Among other things, the ListCellRenderer shows a
JProgressBar that is updated by an outside event. The item itself has an
observer to notice that it has been updated, but other than calling
repaint on the whole JList, I can't seem to make it repaint the cell that
changed.

Signature
Paul Tomblin <ptomblin@xcski.com> http://xcski.com/blogs/pt/
I think I'd like to see a Simpsons episode starting up with Bart Simpson
writing 'I will not attempt to undermine the Usenet Cabal'.
-- J. D. Falk
Oliver Wong - 25 Jan 2006 21:51 GMT
>I have a JList where each item in the list is rendered by a
> ListCellRenderer. Among other things, the ListCellRenderer shows a
> JProgressBar that is updated by an outside event. The item itself has an
> observer to notice that it has been updated, but other than calling
> repaint on the whole JList, I can't seem to make it repaint the cell that
> changed.
Hopefully, you have a javax.swing.ListModel representing all the items
in your list. This ListModel should be keeping track of its
javax.swing.event.ListDataListeners, of which the JList itself is probably
one of the listeners.
You should send your ListDataListeners a "contentsChanged" notification
and provide it with a javax.swing.event.ListDataEvent to tell it
specifically which elements has changed in the list.
See:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/ListModel.html
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/event/ListDataListener.html
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/event/ListDataEvent.html
- Oliver
Vova Reznik - 25 Jan 2006 21:53 GMT
> I have a JList where each item in the list is rendered by a
> ListCellRenderer. Among other things, the ListCellRenderer shows a
> JProgressBar that is updated by an outside event. The item itself has an
> observer to notice that it has been updated, but other than calling
> repaint on the whole JList, I can't seem to make it repaint the cell that
> changed.
Look in
javax.swing.AbstractListModel
and its method
protected void fireContentsChanged(Object, int, int)
Practically you'll need to create your own model extends
AbstractListModel if you don't have one.
Paul Tomblin - 25 Jan 2006 22:36 GMT
In a previous article, Vova Reznik <address@mail.com> said:
>> I have a JList where each item in the list is rendered by a
>> ListCellRenderer. Among other things, the ListCellRenderer shows a
[quoted text clipped - 10 lines]
>Practically you'll need to create your own model extends
>AbstractListModel if you don't have one.
In order to do that, the item would have to propogate the fact that it
changed up to the ListModel, and then the ListModel would have to
fireContentsChanged. I was hoping there was a direct way, but I guess
that will do.

Signature
Paul Tomblin <ptomblin@xcski.com> http://xcski.com/blogs/pt/
You had me at
print("Hello World\n");