使用 JTable 或 GlazedList 创建和使用多个过滤器/搜索
我查找了如何在此处使用常规表格使用多个过滤器,答案都指向 GlazedLists
。但是,答案没有具体说明如何使用它。我能够让一个过滤器工作,但不知道如何让多个过滤器工作。 对于我使用的一个过滤器:
// nameE is a BasicEventList containing classes (name) which
// contain the table values
TextFilterList filtered = new TextFilterList(nameE);
JTextField filterEdit = filtered.getFilterEdit();
// Inside the table value class (name) there is a filter for myName
public void getFilterStrings(List baseList) {
baseList.add(myName);
}
复制代码并创建另一个 JTextField
不起作用。我查了一下这个问题,它出现 CompositeMatcherEditor
可能有效。问题是我不知道如何实现这一点。
另外,我正在使用 Eclipse。我下载了 GlazedLists
1.8.0 并将其放入 Eclipse 中。但是,我无法使用它。我到处都是红色方块(源文件夹除外)!我什至添加了 jar 文件。
我希望我已经正确解释了自己。如果我需要扩展,请告诉我。
I looked up how to use multiple filters on here with a regular table and the answers all pointed to GlazedLists
. However, the answers didn't specify how to use it. I was able to get one filter to work but do not know how to get more than one.
For one filter I used:
// nameE is a BasicEventList containing classes (name) which
// contain the table values
TextFilterList filtered = new TextFilterList(nameE);
JTextField filterEdit = filtered.getFilterEdit();
// Inside the table value class (name) there is a filter for myName
public void getFilterStrings(List baseList) {
baseList.add(myName);
}
Duplicating the code and creating another JTextField
does not work. I looked this problem up and it appears CompositeMatcherEditor
may work. The problem is I do not know how to implement this.
Also, I am using Eclipse. I downloaded GlazedLists
1.8.0 and dropped it into Eclipse. However, I can't use it. I have red squares all over (except for the source folder)! I even added the jar file.
I hope I have explained myself correctly. Please let me know if I need to expand.
My Pastebin: Name, Browser, TableFormat, TableModel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TextFilterList 已弃用 - 请参阅 javadocs - 但这是一个附带问题。
您可以在这里使用多种方法 - 如果您想要非常简单,那么只需将您的过滤器列表包装在另一个过滤器列表中:
更好的方法是使用多个匹配器编辑器来创建 CompositeMatcherEditor:
您可以使用 setMode 来控制编辑器是否使用 AND 组合或或行为。
以下是有关使用过滤器列表的必读信息。
此处提供的截屏视频也值得花几分钟的时间。
TextFilterList is deprecated - see the javadocs - but that's a side issue.
There are several approaches you can use here - if you want really simple, then just wrap your filter list in another filter list:
A better way is to use multiple matcher editors to create a CompositeMatcherEditor:
you can use setMode to control whether your editors are combined using AND or OR behavior.
Here's Must Read info on using filter lists.
The screencasts available here are also worth the few minutes investment.