This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes disabling rows in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "disabling rows in JTable" Watch "disabling rows in JTable" New topic
Author

disabling rows in JTable

alex earnshaw
Ranch Hand

Joined: Nov 05, 2001
Posts: 60
How can I disable individual rows in my JTable?
I am using isCellEditable to make all the cells in the row uneditable, but I also want them greyed out...
I have tried using getCellRenderer to get the renderer for the cells in the row and then call setEnabled(false) on the renderer - but this makes all the cells in the whole table greyed out!
Can anyone tell me where I'm going wrong?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Implement a renderer that detects if the cell is editable and disables or enables itself appropriately...

Since you may be trying to do it the "backwards way" through the model because you are using different renderers and don't want to change each of them, I'll make this a "wrapper renderer" that takes a current renderer as a constructor parameter and delegates all the drawing to that renderer first. All you have to do to use this in your table is to call new EnableWrapperTableCellRenderer( oldRenderer ) whenever you set a renderer on your table or column.



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
 
subject: disabling rows in JTable
 
Similar Threads
Cannot uncheck JCheckBox in JTable
Color in JTable
Using cell editors in JTable
Row Highlight on a JTable
JTable width and height