简体   繁体   English

用多视图填充JList

[英]Populating a JList with multiplte Views

I have the following problem: 我有以下问题:
I want to populate several JLists with the class "Worker". 我想用“ Worker”类填充几个JList。 In the Worker Class, there is a field of WorkerType (an Enum). 在Worker类中,有一个WorkerType字段(一个Enum)。 The ListModel for each View should be the same Type and same Instance, so that when a Worker gets deleted in one View it shouldn't be visible in the other Views anymore. 每个视图的ListModel应该具有相同的类型和实例,以便在一个视图中删除Worker时,该视图模型不再在其他视图中可见。 Is this possible? 这可能吗?

Might be easier to use a single column JTable. 使用单列JTable可能会更容易。 A JTable supports filtering, so each view can be created to show only a specific worker type. JTable支持过滤,因此可以创建每个视图以仅显示特定的工作程序类型。

Read the section from the Swing tutorial on Sorting and Filtering for more information. 阅读Swing教程中有关排序和过滤的部分,以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM