• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Updating data in the JTable cells

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic