• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieve edited value from the cell of a JTable  RSS feed

 
sharath kv
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am trying to retrieve the edited value from the
cell of a JTable but I am getting the old value
itself.
My code is as follows:
public void mouseReleased(MouseEvent e)
{
int x = table.getSelectedRow();
int y = table.getSelectedColumn();
String value = table.getValueAt(x,y).toString();
System.out.println(" Old Value is : " + value);
if(table.isCellEditable(x,y))
{
table.editCellAt(x, y);
JTextField tf = (JTextField)table.getCellEditor().
getTableCellEditorComponent(table, value, true,x,y);
tf.selectAll();
tf.getCaret().setVisible(true);
Object new_value=table.getModel()
.getValueAt(x,y);
System.out.println("New Value is : " + new_value.toString());
} // END OF if(table.isCellEditable(x,y))
} // End of mouseReleased
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!