使用JCheckBox的图标 [英] Using icons with JCheckBox
问题描述
我有一个swing应用程序,我想在其中使用带有图标的JCheckbox。我构建了如下图标:
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);
当我这样做时,标签和图标出现在我的GUI中,但是盒子本身不在哪里被发现。如果我构建没有图标的JCheckBox,则框会回来。我已经尝试调整按钮的首选尺寸,但它没有任何效果。
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?
谢谢,
Elliott
推荐答案
正在使用图标代替框。考虑创建一个紧挨着放置的JCheckBox和JLabel,让JLabel保持ImageIcon。
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.
这篇关于使用JCheckBox的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!