This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi Folks, If anyone can PLEASE help I would greatly appreciate it. Basically, I'm trying to set the background color of a cell in a column of a JTable based on it's value. BUT, when I use this, sometimes a cell will not get it's appropriate color correctly. Most notably, the first line does not seem to update correctly with the new color unless I drag a selection over it and then release it. It's as if the color choice from other columns is bleeding over to this column. Also, scrolling the scrollbar (JScrolPanel) using the arrows at the ends causes odd painting and bleeding to occur. I am using JBuilder 5.0 as my IDE, but can duplicate this using the standard jdk 1.3.1 Here's some code nuggets. This is the interface I use to set up my generic cell color chooser...
And here is the renderer:
And here is the actual color picker I am using:
And the place I add it to the table:
The AlignmentTableCellRenderer is simply another renderer that aligns the text right-justified.
=========================<BR>Jim Hare<BR>Bank of America<BR>firstname.lastname@example.org
Joined: Nov 08, 2001
Hmmm, to make matters more interesting, if I change my highlighter to a DefaultTableCellRenderer and set the colors on the setValue call instead (as follows), the problem goes away! Has anyone else had issues with using getTableCellRendererComponent or chaining renderers together? Here's my new renderer: