wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JTable problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable problem" Watch "JTable problem" New topic
Author

JTable problem

abki kumar
Greenhorn

Joined: Jul 03, 2003
Posts: 3
hi ,
i have implemented a class extending abstract table model and that class is displaying tha data from the resultset through a table .
how can i edit the table cell , so that new value takes place of old value in the cell
can u help me in this?
thanks
abki
Abhik Sarkar
Ranch Hand

Joined: Jun 14, 2003
Posts: 61
Hi,
In the class that you extend from AbstractTableModel, you must override two methods:
isCellEditable must return true for all cells which you want should be editable. If you want that all cells should be editable just do:

This will allow users to edit values in the table.
Now, to capture what value the user has passed, you have to override the setValueAt method. This method will be called when the user has finished editing a cell. The new value is passed as the first parameter. With this new value, you must do whatever it takes to make sure that a subsequent call to getValueAt on the same cell returns the new value (if the new value is acceptable).
I am sure you will be able to find examples of what you are trying to do somewhere in this forum.
Hope this helps,
Abhik.
[ July 04, 2003: Message edited by: Abhik Sarkar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable problem
 
Similar Threads
SetEditable is not working with combobox
JTable Trouble
query
How can I add listeners to JTable cells?
button in a table