• Post Reply Bookmark Topic Watch Topic
  • New Topic

Updating data in the JTable cells  RSS feed

 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How do I update the data in the JTable cells the moment I key in some data after double clicking the cell & entering the data ?!!i.e How do I need to manipulate the getValueAt & setValueAt methods of the Table model such that I don't have to click on a different row and then only the data in the cell gets updated .Right now, this is what is happening.
public Object getValueAt(int row, int column)
{
Vector temp = (Vector)dataEntries.elementAt(row);
return (Object)temp.elementAt(column);
}
public void setValueAt(Object value, int row, int column)
{
Vector temp = (Vector)dataEntries.elementAt(row);
temp.setElementAt(value, column);
}
Thanks
Meghna
 
Swamy Vatti
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this code in the action after table update(eg click save button).
int row = table.getEditingRow();
int col = table.getEditingColumn();
if (row != -1 && column != -1)
table.getCellEditor(row,column).stopEditing()
I guess there is no other way around this!!!
 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi swami
Thanks for the immediate response. Could you please tell me where I need to add the code you've specified ?!!
Thanks
Meghna
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!