Speed Swing Setup

Speed Swing Setup

In Swing 0.7, and probably later versions as well, the DefaultListModel class notifies its ListDataListeners every time a new element is added to the list model. For very large lists this can result in extremely slow JList updates. To work around the issue, set the JList’s model to null before updating the list, then reset the JList’s model when you’re through. This way no expensive event signaling is performed, speeding up your list update. Don’t forget to repaint and revalidate the JList, because a JList does not update its appearance after setModel() is called.

A short demonstration follows. Note that we actually clear the list and refill it with new data, which requires making sure the selection gets cleared and that the top of the list is visible.

 list.setModel(null);listModel.removeAllElements();for(int i=0; i < files.length; i++) {	if(!files[i].isDirectory())		listModel.addEelment(files[i]);}list.setModel(listModel);list.clearSelection();list.ensureIndexIsVisible(0);list.repaint();list.revalidate();
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular