[英]JAVA - Filtering through a linked list
I have a class that reads from a text file, splits the string by a delimiter and adds them to an object depending on the first line. 我有一个从文本文件中读取的类,通过分隔符拆分字符串,并根据第一行将它们添加到对象。
Now everything adds to a linkedlist which later get all represented in a JTable. 现在,所有内容都会添加到一个链表中,以后会在JTable中显示所有链表。
In the GUI I have a JComboBox with various Categories. 在GUI中,我有一个带有各种类别的JComboBox。 What I want is to filter the JTable according to the selected item.
我想要的是根据所选项目过滤JTable。
This is a screenshot to help you understand more: 这是一个截图,可以帮助您了解更多:
Code: 码:
How do I do this? 我该怎么做呢?
You can use a javax.swing.table.TableRowSorter
for sorting and filtering: See TableRowSorter . 您可以使用
javax.swing.table.TableRowSorter
进行排序和过滤:请参阅TableRowSorter 。 You'll probably have to implement your own (simple) javax.swing.RowFilter
, see RowFilter . 您可能必须实现自己的(简单)
javax.swing.RowFilter
,请参阅RowFilter 。
An example: http://www.javapractices.com/topic/TopicAction.do?Id=163 例如: http : //www.javapractices.com/topic/TopicAction.do?Id=163
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.