• Post Reply Bookmark Topic Watch Topic
  • New Topic

no editing for JTables  RSS feed

 
sachin dabhade
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i want to know if there is any method where i can avoid the user to change the valued in JTable.
i have a JTable dynamically created after fetching data from database.
but the user can manipulate this data.
i dont want this to happen.
any way??
thanks in advance.
sachin
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the isCellEditable( int row, int col ) method in TableModel... you need to override this to always return false if you don't want the user to edit the table data.
 
keiyia jackson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this. i used it for a project i was working on. call the method from your code.
public boolean isCellEditable(int row, int col)
{
return false;
}
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!