user105413 user105413 - 3 years ago 136
Java Question

Is there a lazy loading implementation of JList?

Is there a way to implement lazy loading with Swing's JList?

Answer Source

In a way, yes. You can create a custom ListModel which uses the getElementAt(int index) method to load the correct value if it hasn't already been loaded. See the example in the Javadocs for JList:

// This list model has about 2^16 elements.  Enjoy scrolling.

ListModel bigData = new AbstractListModel() {
    public int getSize() { return Short.MAX_VALUE; }
    public Object getElementAt(int index) { return "Index " + index; }
};
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download