Using Icons with JCheckBox

I have a swing application in which I want to use JCheckbox with an icon. I built the icon as follows:

   JCheckBox unsubmit = new JCheckBox("Unsubmit",applet.undo);

When I do this, the shortcut and icon appear in my GUI, but the box itself is not where it can be found. If I build a JCheckBox without an icon, the box will return. I tried adjusting the size of the buttons, but this did not affect.

Does anyone know what is going on here?

Thank,

Elliot

+5
source share
1 answer

The icon is used instead of the field. Consider creating JCheckBox and JLabel placed right next to each other, and JLabel holds ImageIcon.

+10
source

All Articles