aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Update Jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Update Jtable" Watch "Update Jtable" New topic
Author

Update Jtable

Chandra Mohan
Ranch Hand

Joined: Oct 06, 2003
Posts: 62
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
Jhedzkie Skies
Ranch Hand

Joined: Oct 28, 2009
Posts: 118
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

Joined: Jun 13, 2009
Posts: 2090
    
    7
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

Joined: Apr 24, 2010
Posts: 79
But in SetValueAt() method we also need to write firetablecellchangesupdate() method.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Update Jtable
 
Similar Threads
NX: working with JTable
Add an editable row to an non editable JTable
Editing in a JTable
Editing JTable
JTable