• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

disabling rows in JTable

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic