So I have successfully implemented a search feature into my tiny program but when I click the button to sort, it works fine but the images don't display. This is the code that I added for the sorter which works fine but the images for each row don't show up. When I take out this code, the images show up but the sorting doesn't work. Is there away that I can make the images show when sorting?
// Sorter Code. Images show up when this code gets taken out.
table = new JTable(model);
final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
table.setRowSorter(sorter);
search_button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = search.getText();
if (text.length() == 0) {
sorter.setRowFilter(null);
} else {
sorter.setRowFilter(RowFilter.regexFilter(text));
}
}
});
// sorter code ends here.
have to synchronize
JTable
s view with its model,have look at methods
convertXxxIndexToXxx
add
int modelRow = convertRowIndexToModel(row);
to yourRenderer
orprepareRenderer
example
convertRowIndexToModel
EDIT