I was working in the same application where I found the previous quirk. This time I tried to make a cell renderer put a background color in the cell, to no avail. I even tried to explicitly return a
The answer to the mystery is the fact that
JLabel as the cell renderer, with the proper background color set. Nothing.The answer to the mystery is the fact that
JLabel is transparent by default, transparent components don't render their background, and DefaultTreeCellRenderer extends JLabel.
Continue reading Java Quirks: JLabel.setBackground() don't "work" by default.