Domanda

I'm building a GUI that includes a list with quite a lot of items. I allow the user to add/delete/edit those items.

Up until now my update method called in the controller implied an entire JList reset (with its obvious performance issues). Now that there are hundreds of items available, updating the entire list is not fezable any longer.

Does anyone know of a tutorial or can share an example (I haven't found any to suit my needs so far) in which the JList is updated something like JList.update(startIndex, endIndex);?

Thanks for taking the time to answer.

È stato utile?

Soluzione

List listens to change events from its ListModel. Did you try updating the model without setting a new one on each change?

Looking at DefaultListModel interface it should be possible, there are methods to modify it, such as addElement, removeElement, etc.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top