• 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

problems with cell renderer, please help

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,
I'm trying to write my own cell renderer so that I can highlight the tableRow the user has doubleclicked with a different color than the row that was clicked just once. But it just won't work. Can you please help me ?
I wrote a DoubleClickTable that extends JTable. I added a MouseListener that registers the number of the row that the user has doubleclicked. There can not be more than one row doubleclicked at a time. This works fine.
Then a added an inner class as follows :

In DoubleClickTable I override getCellRenderer() :

where rowRenderer an instance is of my inner class TableRowRenderer
Thanks.
A
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to set the cell renderer, you need to get the instance of TableColumn for all the columns and assign the cell renderer:

The method you have been calling, getCellRenderer() in JTable is never called by the runtime. Right now, it returns the default table cell rederer to the caller which is no one in your case.
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic