I have a swing application in which I want to use a JCheckbox with an icon. I constructed the icon as follows:
JCheckBox unsubmit = new JCheckBox("Unsubmit",applet.undo);
When I do this, the label and the icon appear in my GUI but the box itself is no where to be found. If I construct the JCheckBox without the icon, the box comes back. I've tried adjusting the buttons's preferred size but it had no effect.
Anyone know what's going on here?
Thanks,
Elliott
A checkmark will be used to choose a box. JCheckBox often uses the methods isSelected and setSelected. To select, or un-select, a box, use the setSelected(boolean) method. To check if a box is selected, use the isSelected() method.
JCheckBox is an implementation to checkbox . JCheckBox inherits JToggleButton class. Constructor of the class are : JCheckBox() : creates a new checkbox with no text or icon.
The Icon is being used in place of the box. Consider creating a JCheckBox and a JLabel placed immediately next to each other, and have the JLabel hold the ImageIcon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With