How to make the background of a JCheckBox transparent?

java, swing

Solution

setOpaque(false);

That line will make the background of the `JCheckBox` not be drawn. It will be the color of whatever `Component` it is on.

If you are subclassing a `JCheckBox`, just place that line in the constructor. Otherwise call it on an instance of the `JCheckBox`.

Problem

Is there an easy way to make the background of a `JCheckBox` transparent? The box itself and the text should both be ordinary colored.

Original source