Having read here and not understood the concept, I had to post my issue here. I am trying take the input value from Keyword JTextField
and filter my JTable
table_job
.
When search button is pressed, it should change the table in Job List
panel to only display the set of jobs which includes the keyword in any of the column in its table. Currently, I am having no luck and am getting blank screens.
Here is the Job List Screen
The table on right does not update according to keyword.
Here is what I tried and failed, I am new to table filtering.
try {
jobTableInit();
String value = keyword.getText();
TableRowSorter sorter;
sorter = new TableRowSorter<DefaultTableModel>(new DefaultTableModel());
RowFilter<DefaultTableModel, Object> rowFilter = null;
try {
rowFilter = RowFilter.regexFilter(keyword.getText());
}
catch(java.util.regex.PatternSyntaxException ex) {
return;
}
sorter.setRowFilter(rowFilter);
table_job.setRowSorter(sorter);
}
catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
Can somebody suggest recommendations or show me a simple example code?