Hi,
I have a JTree with a custom icon renderer that displays an icon. The JTree is part of a TreeTable component. Iam having a problem setting the selection background uniformly for the entire row. There is no problem when there is no row selected in the JTable.
My present code looks like this:
Iam overriding paint in my renderer which extends DefaultCellRenderer.
super.paint(g);
Color bColor = null;
if(!m_selected) {
if(currRow % 2 == 0) {
bColor = Color.WHITE;
} else {
bColor = backColor;
}
} else {
bColor = table.getSelectionBackground(); bColor = getRowSelectionColor();
}
if(bColor != null) {
g.setColor(bColor);
if(!m_selected) {
g.setXORMode(new Color(0xFF, 0xFF, 0xFF));
} else {
g.setXORMode(new Color(0x00, 0x00, 0x00));
}
I have a color I arrive at using some algorithm that I want using method getRowSelectionColor(). The other cells in the row have this color. But the cell containing the tree node shows different color. Iam not able to arrive at the right combination of the color to set and the xor color so my tree node also looks like the other cells in the row.
It is not a problem really as the table still looks good. Its just that the tree node looks like it has been highlighted and this might cause a problem when a table cell is highlighed later on in the application ( two cells in the row would be highlighted causing confusion).
Any help would be appreciated.
Regards,
vidyut