Une question sur la recherche dans une JTable
Bonjour,
J'ai fait le code suivant pour filtrer ma table et trouver une ligne qui contient le mot cherché
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| jtfFilter.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
String text = jtfFilter.getText().toLowerCase();
// System.out.println(text);
if (text.trim().length() == 0) {
rowSorter.setRowFilter(null);
} else {
rowSorter.setRowFilter(RowFilter.regexFilter("(?i)"+text));
}
table.repaint();
}
public void removeUpdate(DocumentEvent e) {
String text = jtfFilter.getText().toLowerCase();
if (text.trim().length() == 0) {
rowSorter.setRowFilter(null);
} else {
rowSorter.setRowFilter(RowFilter.regexFilter("(?i)"+text));
}
table.repaint();
}
public void changedUpdate(DocumentEvent e) {
//not needed: throw new UnsupportedOperationException("Not supported yet.");
}
}); |
Ma question est : comment je peux faire la recherche sur une colonne unique ?
Merci