问题描述
上面有很多行显示了jtable.我想按短代码过滤记录.如果我输入短代码,例如 1234 ,则应该在jtable上仅显示与短代码 1234 相关的行.
There are many rows on above showing jtable. I want to filter record by short code. If I type short code like 1234 it should be display only short code 1234 associated row on jtable.
谢谢
推荐答案
You're going to have write the code...Start by checking out how to use tables, in particular sorting and filtering
基本要求是将ActionListener
附加到字段和按钮上(如果需要,可以从表单编辑器执行此操作).
The basic requirement would be to attach an ActionListener
to both the field and button (you can do this from the form editor if you wish).
在actionPerformed
事件处理程序方法中,您需要创建一个RowFilter
并将其应用于表RowSorter
.
Within the actionPerformed
event handler method, you need to create a RowFilter
and apply it to the tables RowSorter
.
通过将autoCreateRowSorter
属性设置为true
,可以将表配置为自动创建行排序器.
A table can be configured to automatically create a row sorter by setting the autoCreateRowSorter
property to true
.
在链接的教程中都对它进行了很好的解释...
It's all explained nicely in the linked tutorials...
和另一个示例
这篇关于如何使用NetBeans IDE使可过滤到JTable记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!