• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update Jtable

 
Chandra Mohan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have used Jtable to display the data in tabluar format with help of AbstractTableModel. The Jtable has non editable mode. For some operation (click button), I need to update the particular cell. Is there any option to update the Jtable in non editable mode (or how to make it editable then revert back the previous mode) and at the end of the process Jtable should be non editable mode. Is there any solution for this issue ?

Regards
mohan
 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could try to use the fire methods i believe.


put the method on your so called button and at the end of the procedure of the button,
put

 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know table.setValueAt(...) should work.

If not, then you can update the model directly by using table.getModel().setValueAt(...);
 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But in SetValueAt() method we also need to write firetablecellchangesupdate() method.
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But in SetValueAt() method we also need to write firetablecellchangesupdate() method.


Not sure what your point is.

If you use the DefaultTableModel then this is done for you automatically.

If you use a custom TableModel then, yes, you need to add the code yourself. Thats why I recommend you use the DefaultTableModel unless you have a specific reason to create a custom model. Its less work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic