[英]JTable custom RowFilter?
RowFilter 示例僅進行文本比較,但是如何過濾鏈接到特定屬性的行?
我的數據模型類
class MyDataModel
{
private ArrayList<MyFile> data; // for the rows data
...
class Myfile
{
private boolean error; // file name issues
private boolean ignored; // file ignored for process
private boolean exception; // file processed no matter other conditions
...
那么如何過濾 MyFile 具有某些屬性為 true 的行(或者對這些字段進行更復雜的測試)
謝謝
文本比較是什么意思? 您是否添加了過濾器並覆蓋了包含方法?
boolean include(RowFilter.Entry<? extends M,? extends I> entry)
此處的 API 文檔RowFilter本身解釋了如何根據整數/數字或任何屬性類型進行過濾
RowFilter<Object,Object> filter = new RowFilter<Object,Object>()
{
public boolean include(Entry<? extends Object, ? extends Object> entry)
{
int rowID=(Integer)entry.getIdentifier();
FilesTableModel data=(FilesTableModel) entry.getModel();
return data.isVisible(rowID);
}
};
TableRowSorter<FilesTableModel> sorter = new TableRowSorter<FilesTableModel>(data);
sorter.setRowFilter(filter);
table.setRowSorter(sorter);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.