• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable with both editable and uneditable cells

 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
is it possible for a JTable to have both editable and uneditable cells.

thanks in advance,
lavanya
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. That is what the isCellEditable() method is for. Look in DefaultTableModel.
 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Stevens,
thanks, i fixed the problem,

lavanya
 
Andre Dumais
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A spin off question on this one. How can one set the cells of table to be non-editable. I am using a JTable to diplay/modify a set of parameters and I only wnat one of two columns to be editable.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DefaultTableModel has a isCellEditable() method that will do this. You can either take a look at the API or just do a search within this forum and find examples.
 
Priya Ramesh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andre,
Inorder to make one of the Columns editable and the other one non - editable, you can have a your own Table Model Class derived from AbstractTableModel and in your isCellEditable function, check for the Column that you want to make it editable and return true.


[ March 06, 2002: Message edited by: Priya Ramesh ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!