是否有JList的延迟加载实现? [英] Is there a lazy loading implementation of JList?

查看:33
本文介绍了是否有JList的延迟加载实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以通过Swing的JList实现延迟加载?

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

推荐答案

从某种意义上讲,是的.您可以创建自定义 ListModel 使用 getElementAt(int index) 方法以加载正确的值(如果尚未加载).请参阅Javadocs中的 JList 的示例>:

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; }
};

这篇关于是否有JList的延迟加载实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆