DefaultTableModel model2 = (DefaultTableModel) mytable.getModel();
What is the difference between these two?
model2.getValueAt(row,column);
mytable.getValueAt(row,column);
DefaultTableModel model2 = (DefaultTableModel) mytable.getModel();
What is the difference between these two?
model2.getValueAt(row,column);
mytable.getValueAt(row,column);
From the JavaDoc - if you use JTable.getValueAt(int, int)
, you'll get the column in the table's visible column order. If a user reorders columns, the view and the model may not be in sync.
"Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering."
model.getValueAt(row, column)
for (int count = 0; count < model.getRowCount() ; count++)
{
System.out.println( model.getValueAt(count, 0).toString());
}