i want to select particular rows from the JTable which contains a particular string.. please help me for this..
-
Call JTable.getModel then just loop through using TableModel.getValueAt
From Matthew Flaschen -
Something like this will do the trick:
void selectMatchingRows(JTable table, String regex) { for (int row = 0; row < table.getModel().getRowCount(); row++) { for (int col = 0; col < table.getModel().getColumnCount(); col++) { if (table.getModel().getValueAt(row, col).toString().matches(regex)) { table.getSelectionModel().setSelectionInterval(row, row); } } } }Making sure the
ListSelectionModel.selectionModeisMULTIPLE_INTERVAL_SELECTION.From Nick Holt

