aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes [JTable] Non editable cells on editable column 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] Non editable cells on editable column" Watch "[JTable] Non editable cells on editable column" New topic
Author

[JTable] Non editable cells on editable column

Francois Dereims
Greenhorn

Joined: May 01, 2008
Posts: 11
Hi there.

In my JTable, I have a column where all cells are editable to let the user enter values.
Once those values have been saved in the database, I'd like to refresh the JTable and set non editable the cells with a value to prevent all modification. Blank cells must remain editable.
I'm not sure on how to implement this (as the whole column is supposed to be editable).
Any idea ?
Stanislav Lapitsky
Ranch Hand

Joined: Dec 01, 2009
Posts: 53
Use public boolean isCellEditable(int row, int column) method of table or the same method of your TableModel and return false for the non editable values.

Regards,
Stas
Francois Dereims
Greenhorn

Joined: May 01, 2008
Posts: 11
Sorry but I actually don't see...
The matter is to make specific cells dynamically uneditable. How is it possible in the TableModel ? Any example, please ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

isCellEditable takes a row and column. You can use these to return true or false on each separate invocation.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [JTable] Non editable cells on editable column