Java glazedlists: how to update a table row
I'm missing something obvious here.
I have a glazedlists EventList<X>
where X
is my custom class. This list contains a bunch of values. When I update one of the values, how do I make sure开发者_JS百科 the GUI updates its display for that row?
It looks like you can invoke addListEventListener to register a ListEventListener. See also the Glazed Lists Tutorial.
The FAQ mentiones two ways under the question:
How do I tell Glazed Lists that an Object in my EventList has been updated?
Either you use the get/set approach as pointed out by Jason, or you make the elements in the list observable by for instance the PropertyChangeListener
and then use the ObservableElementList
. I think this second approach is cleaner and it should also work with concurrent threads.
The way to do this appears to be to replace the list element with itself:
EventList<X> list = /* get reference to a list */
X x = list.get(3);
/* update x here */
list.set(3,x);
精彩评论