public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column
) {
if (isSelected) {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
boolean tableHasFocus = (focusOwner == this) || (focusOwner == TreeTable.this) ||
TreeTable.this.isAncestorOf(focusOwner) || focusOwner instanceof JRootPane;
setBackground(tableHasFocus ? table.getSelectionBackground() : getUnfocusedSelectedBackground());
setForeground(tableHasFocus ? table.getSelectionForeground() : getUnfocusedSelectedForeground());
} else {
setBackground(table.getBackground());
setForeground(table.getForeground());
}
visibleRow = row;
return this;
}