Hi All,
I have a JTable with DefaultTableModel as model.
When I first populate table with data(from database), I am storing the table data locally in a vector, using
Vector cols; //this is initialized with column names.
Vector data = ((DefaultTableModel)table.getModel()).getDataVector(); This table is editable, when user changes data and hits save, if any problem occurs while saving, I want to reset table data to previous values . So, I am trying to reset table data as below.
((DefaultTableModel)table.getModel()).setDataVector(data, cols); But it does't work, the vector
data now has the current values that user has modified to, not the previously stored values.
I also tried to store data by doing a copy of the data as below,
Vector tempV;
tempV = ((DefaultTableModel)table.getModel()).getDataVector();
Object [] tempAr = new Object[tempV.size()];
tempV.copyInto(tempAr);
vector= new Vector(Arrays.asList(tempAr));
Even then it has the current value.
Appreciate if anybody can help ...
Thanks in advance.
-Ssh