• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting cell editor false in DefaultTableModel  RSS feed

 
Manoj Tyagi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a JTable using DefaultTableModel. But by default, my table cells seems to be editable ie whenever i double click on any cell area, i can add/delete anything to it. Though i am just using it to show the database values & not doing any update but still i want that my cells should not seem to be ediable.
How can i do it?
Manoj Tyagi
 
Marcel de Jong
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manoj,
take a look at the Tutorial on Tables.
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
Marcel
 
Jeremy Maddera
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
override the isCellEditable method...

This will fix you issue....
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just another hint:
You have to write your own TableModel. When the only feature should be, that the cells are not editable, then it will be enough to extend from DefaultTableModel. Then you can overwrite the isCellEditable method as it was suggested before.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!