What an interesting challenge. This problem has been bugging me in the back of my brain every since I read it, and I've been hoping somebody would come up with a solution. I finally found some time this morning to mess around with it, and so far, this is all I have been able to come up with that approximates what you've asked for. It's definitely not a finished product, but at least it's a direction you could explore:
Here is the script that runs in the configureCell extension function:
#def configureCell(self, [...], colView):
from java.awt import GradientPaint
from java.awt.image import BufferedImage
from javax.swing import ImageIcon
if selected:
return {'background': self.selectionBackground}
if rowView % 2 == 0:
colorOne = system.gui.color(255,0,0)
colorTwo = system.gui.color(0,255,255)
else:
colorOne = system.gui.color(0,255,0)
colorTwo = system.gui.color(0,0,255)
text = textValue
font = self.font
renderer = self.table.defaultCellRenderer
editor = self.table.getCellEditor(rowIndex, colIndex)
cellRect = self.table.getCellRect(rowIndex, colIndex, True)
gradient = GradientPaint(0, 0, colorOne, cellRect.width, cellRect.height, colorTwo)
image = BufferedImage(cellRect.width, cellRect.height, BufferedImage.TYPE_INT_ARGB)
graphic = image.createGraphics()
graphic.setPaint(gradient)
graphic.fillRect(0, 0, cellRect.width, cellRect.height)
fontMetrics = graphic.getFontMetrics(font)
textWidth = fontMetrics.stringWidth(text)
textHeight = fontMetrics.height
x = int(0.5*(float(cellRect.width) - float(textWidth)))
y = int(0.5*(float(cellRect.height) + float(fontMetrics.ascent - fontMetrics.descent)))
graphic.setColor(system.gui.color(255, 255, 255))
graphic.setFont(font)
graphic.drawString(text, x, y)
graphic.dispose()
renderer.icon = ImageIcon(image)
renderer.text = None
return {'renderer':renderer}
Basically, the script replaces the text with a gradient image that has the text drawn on it. However, if the cell is selected, it does not do this. The script does not work with a boolean column, although it could if it were developed further to draw the checkbox. Also, it exhibits some unexpected behavior if auto row height is selected. I'm guessing it's because he cellRect.height property is slightly taller than the row height forcing a resize when repaints occur. If the autoRowHeight property is important to your table, it could probably be fixed by calculating the image height a different way.