Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whitehexagon

macrumors regular
Original poster
May 12, 2007
147
0
This only fails under OSX.

I have:

Code:
class ColorTableHeaderRenderer extends JLabel implements TableCellRenderer

where I override the paint method to draw a custom colored box & font into the label.

So for each table column I do something like this:

Code:
col.setHeaderRenderer(new ColorTableHeaderRenderer(getColorForColumn(colIndex)));

At runtime this draws the text, but all the fillRect() statements seem to fail! However if I replace setColour and fillRect with setBackground and clearRect. Then when I scroll the table to the right. The newly revealed column header appears correct, and when I scroll the table left again, the first columns render correct.

It seems like some strange painting optimization is going on with the headers that fillRect is being ignored, and also that the headers are not fully painted. As I mentioned this seems to OSX specific, the same code works fine under windows and linux.

I also tried many variation with just tweaking attributes of the Label with the required color, eg the border, a custom drawn icon full of the color, the background, the foreground. In all cases it's as though the statements are being ignored. The colour being held in each renderer instance looks fine.

Any tips?
 
bah, you can ignore the above. The problem was related to accidental use of alpha values in the colors being used for the setColor statements.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.