JavaSwingJList and ListModel: ListModel


ListModel

See also: Observable lists

Events

contentsChanged

Unfortunately there is no clear statement in the specification what exactly may have changed.

First of all it is used for the both cases: a) the item (i.e. the reference) was changed b) some property of the item changed that might concern the appearance.

Problem: In general you cannot not what property of the items might be of interest for the current ListCellRenderer, so you basically have to fire this event if any property changed for a general-purpose ListModel.

In the following text, "changed" means one of these things.

One problem is that generally I would say, if case a) happened, the item should be deselected if it was, since it is not the same anymore, while in case b) it should not. As JList cannot possibly distinguish between the events (without caching the whole ListModel's contents), the item always remains selected.

I distinguish between the following types of changes:


(C) 2001-2009 Christian Kaufhold (swing@chka.de)