java - 为什么 Sorted JLists 还没有成为标准 Swing 库的一部分?

标签 java swing jlist sorting

Creating a Sorted JList Component”说,

Version 6 of the Java Platform, Standard Edition (Java SE, formerly referred to as J2SE) will add sorting and filtering abilities to the javax.swing.JTable class.* The Java Foundation Classes/Swing (JFC/Swing) engineering team has added a TableRowSorter class to Java SE 6 to handle sorting and filtering. This class behaves like a decorator in that it represents the underlying table model and adds sorting to it at runtime. You create a TableRowSorter object by providing the original table model in the constructor. Then you call the table's setRowSorter method. Thereafter, the JTable object will use the TableRowSorter object to get a sorted representation of the base model. Unfortunately, this same feature is not yet available for the JList class, nor will it be available in the next release. But we can borrow the decorator idea to create a SortedListModel class that adds sorting abilities to any ListModel object. Note: The demo application and code in this article apply to all versions of the JDK through version 6.

有没有人听说他们计划将它包含在 Java 7、8 或 9 中?因为这就是它给我的感觉:

Lists are appropriate UI components for many applications, but an unsorted list has limited usefulness.

(我强调的)

最佳答案

无法说明原因 - 如果您需要可排序的 ListView ,请使用 JXList(属于 SwingX 项目):它支持按照与 J/X/Table 完全相同的方式进行排序/过滤。

关于java - 为什么 Sorted JLists 还没有成为标准 Swing 库的一部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8454931/

相关文章:

java - int 数组初始化

java - 如何为我的 Fluent API 构建接口(interface)层次结构?

java - 如何在 JTextArea 中显示整数数组?

java - JTable 单元格监听器 JAVA

java - 将数据从 netbeans 中的另一个表单添加到 JTable

java - 无法从选定的多行 Jlist 中获取每个项目?

java - 尝试在聊天事件(Minecraft、Spigot)上设置玩家显示名称时出错

Java 作用域和可见性规则

java - 为什么在通过列表模型更新内容后有时会得到空白的 JList?

java - JList中拖选