• Post Reply Bookmark Topic Watch Topic
  • New Topic

Disabling multiple single cells

 
Lila Fowler
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Im trying to disable certain cells in a single row based on what the user selects in the first cell. I'v wrote a mini version of my problem.
I looked at the other threads that asked the same basic question but i cant get my isCellEditable method to work(always returns true).
Any ideas as to what i'm doing wrong?

Here is my code



Thanks
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is exactly what isCellEditable is for. You can use complex calculations in it, and even return true only if another cell has a specific value. For instance:
Now only if the value in the first column equals "Some Value" will the remainder of the row be editable.
 
Lila Fowler
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob but It doesn't work it seems as if my code doesn't even go into the isCellEditable()...(Any ideas why? I replaced my method with Robs and nothing changes.)

Also I need to disable specific cells in a row added a picture to better explain what i'm trying to do.



Thanks


 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a class extending JTable with a static field of type JTable. go through your code: which one has the overridden isCellEditable? Which one is added to the visible component hierarchy?

You also a static field of type JFrame that's never used plus a local JFrame variable that's populated and shown.

I suggest you make a fresh start and add just a little code at a time, making sure you understand what you're doing. Oh and on the way, compile and test every time you add something new.
 
Lila Fowler
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason there are two frame is because this is just a tiny amount of code from a 7000 lines of code, i must have just missed it. The code does compiles without errors or bugs and it works. I understand it. Its just the isCellEditable that has me stumped. But thanks for the overridden tip.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!