Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[JTable] Non editable cells on editable column

 
Francois Dereims
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isCellEditable takes a row and column. You can use these to return true or false on each separate invocation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic