File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

make cells in JTable uneditable

john latham

Joined: May 28, 2006
Posts: 22

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

Joined: Oct 14, 2005
Posts: 19973

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

Joined: May 28, 2006
Posts: 22
thanks for that, works good
I agree. Here's the link:
subject: make cells in JTable uneditable
It's not a secret anymore!