• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Update Jtable

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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(...);
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But in SetValueAt() method we also need to write firetablecellchangesupdate() method.
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic