File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

JTable problem

abki kumar

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?
Abhik Sarkar
Ranch Hand

Joined: Jun 14, 2003
Posts: 61
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,
[ July 04, 2003: Message edited by: Abhik Sarkar ]
I agree. Here's the link:
subject: JTable problem
It's not a secret anymore!