GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes problems with cell renderer, please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "problems with cell renderer, please help" Watch "problems with cell renderer, please help" New topic
Author

problems with cell renderer, please help

Andrew Collins
Ranch Hand

Joined: Mar 28, 2002
Posts: 42
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
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
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.
 
GeeCON Prague 2014
 
subject: problems with cell renderer, please help