x-ice
Mar 14th, 2008, 05:10 PM
How can I traverse the rows of a JTable to search it?
x-ice
Mar 15th, 2008, 07:46 AM
Problem solved with code that I found on the java swing forum. 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
}
}