permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes How to make only some rows editable in a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make only some rows editable in a JTable" Watch "How to make only some rows editable in a JTable" New topic
Author

How to make only some rows editable in a JTable

sandhya raviprasad
Greenhorn

Joined: Feb 23, 2001
Posts: 6
Hi
I have a JTable with 4 columns and 8 rows. One of the columns has checkboxes with true - false values indicating that if the value of the checkbox is true, then that row should be uneditable, if the cb value is false, then the row should be editable. Please guide me with this.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
The only way that I can think of to do it is to add a Listener to the table. When any KeyEvent occurs look at the checkbox, and if it is set to true, then get rid of the keystroke.


"JavaRanch, where the deer and the Certified play" - David O'Meara
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
Hi sandhya,
to make few rows editable u need to override boolean isCellEditable(int row,int column) method of JTable class.


actually whenever you try to edit some cell then the method isCellEditable() is fired for that row,col pair. so u can override this method to return true/false depending on whatever conditions u have.
hope that was clear.
regards
deekasha


regards
deekasha
Sandhya Rprasad
Greenhorn

Joined: Mar 01, 2001
Posts: 24
Hi deekasha
Thanks, but I'd already solved the problem. But I guess, I picked up on the same thing as u've suggested. Thanks a lot.
I'd really appreciate it if I could get a little fast response.
regards
Sandhya
eric moon
Ranch Hand

Joined: Nov 26, 2000
Posts: 133
Well, Sandhya, instead of complaining, how about answering your own question when you figure it out, so others don't spend their time and energy answering it.
That's what I do. After all, we don't pay to use JavaRanch!


<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>"Those who cast the votes decide nothing. Those who count the<BR>votes decide<BR>everything." <BR> -Joseph Stalin<HR></BLOCKQUOTE>
Sandhya Rprasad
Greenhorn

Joined: Mar 01, 2001
Posts: 24
Originally posted by eric moon:
Well, Sandhya, instead of complaining, how about answering your own question when you figure it out, so others don't spend their time and energy answering it.
That's what I do. After all, we don't pay to use JavaRanch!

Hi Eric
It was not a complain, but it was a suggestion. I'm sorry if you could'nt get to the sensitivity of the solution. If you did observe, I did thank Deekasha for the response which I certainly mean. Ofcourse I am aware that we don't pay JavaRanch to use it and yes, I did find the solution after a lot of struggle and research over the net and stuff. Yes, if the solution given to me did'nt help me much in time, which I'm not blaming, it may help someone else coming up with similar problems in the future.
So, please do put your words after giving it a serious thought when you're posting on such forums .. I'd really appreciate that !!!
Sandhya

Gary F.
Greenhorn

Joined: Apr 25, 2004
Posts: 1
Well, thanks that helped, I new how to get the rows/cols to to enabled are start, but was having trouble with the checkbox and getting thoughs rows only to be editable, with the code provided about it gave me anouther idea.
So thanx for the inital posting and all the replies. , this will help me no my class final project 60% of sem grade


FoxSurfer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make only some rows editable in a JTable