aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes make cells in JTable uneditable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "make cells in JTable uneditable" Watch "make cells in JTable uneditable" New topic
Author

make cells in JTable uneditable

john latham
Greenhorn

Joined: May 28, 2006
Posts: 22
Hi,

How do i make cells in my JTable uneditable. The cells that i want to set this way are checkboxes.

What im trying to do is, Only allow for 3 checkboxes max to be selected in my tabel.

And my logic is...if 3 checkboxes have been selected in the table, make all checkboxes that are not checked uneditable ... i tried the following, but it didnt work:



[ September 11, 2006: Message edited by: john latham ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18902
    
    8

I have no idea what that code is supposed to be doing, but it doesn't appear to deal with whether cells can be edited or not. I would do this: override the isCellEditable method of the TableModel. Have it return false if it's referring to an unchecked checkbox and three other checkboxes are checked, and true otherwise.
john latham
Greenhorn

Joined: May 28, 2006
Posts: 22
thanks for that, works good
 
 
subject: make cells in JTable uneditable