• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to prevent changing cell data in a JTable

 
Kuan Fan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Can anybody tell me how to prevent changing cell data in a Jtable.
I use DefaultTableModel to creat a JTable. I get the data from db.db file( FBN assignment ), I display the JTable. But I don't want to let customers to change the data in cell. How can i do that?
thanks in advance, preciate for your answers!
 
Enrico Mannarino
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stephen,
you must override the method in the DefaultTableModel which alsways return true, like this:
public boolean isCellEditable(int row, int col) {
return false;
}
/enrico
 
Kuan Fan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Enrico,
It works!
thank you very much!!!
stephen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic