You try this

JCheckBox checkbox = new JCheckBox();

checkbox.setText("Enable logging");
checkbox.setSelected(true);
checkbox.setIcon(icon);