使用JCheckBox的图标 [英] Using icons with JCheckBox

查看:155
本文介绍了使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆