public static int removeLastRowsTable(JTable table){
  if (table.getRowCount() == 0) {
    return 0;
  }
  DefaultTableModel model=(DefaultTableModel)table.getModel();
  int count=0;
  while (true) {
    boolean remove=true;
    for (int i=0; i < table.getColumnCount(); i++) {
      String data=getStringValueTable(table,table.getRowCount() - 1,i);
      if (!data.equals("")) {
        remove=false;
        break;
      }
    }
    if (remove) {
      count++;
      model.removeRow(model.getRowCount() - 1);
    }
 else {
      break;
    }
  }
  return count;
}

public static int removeLastRowsTable ( JTable table ) { if ( table . getRowCount ( ) == 0 ) { return 0 ; } DefaultTableModel model = ( DefaultTableModel ) table . getModel ( ) ; int count = 0 ; while ( true ) { boolean remove = true ; for ( int i = 0 ; i < table . getColumnCount ( ) ; i ++ ) { String data = getStringValueTable ( table , table . getRowCount ( ) - 1 , i ) ; if ( ! data . equals ( "" ) ) { remove = false ; break ; } } if ( remove ) { count ++ ; model . removeRow ( model . getRowCount ( ) - 1 ) ; } else { break ; } } return count ; }
remove the last rows of the table that do not contain any data
