i want to select particular rows from the JTable which contains a particular string.. please help me for this..
A:
Call JTable.getModel then just loop through using TableModel.getValueAt
Matthew Flaschen
2009-07-10 09:41:09
A:
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.selectionMode
is MULTIPLE_INTERVAL_SELECTION
.
Nick Holt
2009-07-10 09:47:54