Using icons with JCheckBox

走远了吗. 提交于 2019-12-01 15:48:23

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/11657481/using-icons-with-jcheckbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!