Adding an Icon to the Label of a JCheckBox Component
import javax.swing.JCheckBox;
public class Main {
public static void main(String[] argv) throws Exception {
JCheckBox checkbox = new JCheckBox();
String label = "![]() | | "
// Retrieve the current label text
+ checkbox.getText() + " |
";
// Add the icon
checkbox.setText(label);
}
}