aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable column that can be both editable or non-editable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable column that can be both editable or non-editable" Watch "JTable column that can be both editable or non-editable" New topic
Author

JTable column that can be both editable or non-editable

bill moody
Greenhorn

Joined: Dec 02, 2006
Posts: 2
Hello, i have an application that is stuck with some JTable issues. The first of which is i have a column in my JTable that i want to be editable IF a particular RadioButton is selected, and non-editable otherwise.

Here is a code snippet that i was able to work to get columns editable in my initialization:



Does anyone have any ideas as to how i can make case 0 return true IF a radio button (independent of the JTable but on the same page of my application) is not selected, but false if it is?

A thousand thank yous to the guru who solves my problem!!!
[ December 02, 2006: Message edited by: bill moody ]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Extend your TableModel to turn on/off editing based on columns, then add a listener to the checkbox to call these methods...



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
bill moody
Greenhorn

Joined: Dec 02, 2006
Posts: 2
nathan thank you, this worked like a charm.

Well one point i would make for any future browsers of this was that attempting to integrate Nathan's code into my own, my isCellEditable method was returning false in both sides of the if condition until i realized this and adjusted my cells default values. I ended up just returning false for one side of the condition and returning true for the other side.

Once i did that, it worked like a charm!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable column that can be both editable or non-editable