How can I traverse the rows of a JTable to search it?
Printable View
How can I traverse the rows of a JTable to search it?
Problem solved with code that I found on the java swing forum.Code:DefaultTableModel myTableModel =(DefaultTableModel) myTable.getModel();
for ( int i = 0 i < myTableModel.getRowCount(); i++){
String value = (String) myTableModel.getValueAt(i, 2);
if( value.equals("California"){
// do whatever you want with the match, e.g. break out of loop or continue
}
}