gpt4 book ai didi

java - 添加 ImageIcon 时如何防止 JRadioButton 出现气泡?

转载 作者:行者123 更新时间:2023-12-01 13:42:15 25 4
gpt4 key购买 nike

我正在改进使用 swing 创建的石头、剪刀、布程序,现在我正在为每个 JRadioButton 添加 ImageIcons。我导入并添加了岩石,但我似乎找不到保留气泡的方法

enter image description here

显示在文本旁边。当我添加图标时,我得到了这个。

enter image description here

有什么建议吗?谢谢!

最佳答案

创建一个自定义图标以供选择(可以为当前图标添加边框)。然后您可以如下设置选择图标。

JRadioButton radio = new JRadioButton(new ImageIcon("Resources/nonSelect.png"));
radio.setSelectedIcon(new ImageIcon("Resources/selected.png"));

此外,您还可以设置翻转图标。

radio.setRolloverIcon(new ImageIcon("Resources/rollover.png"));

关于java - 添加 ImageIcon 时如何防止 JRadioButton 出现气泡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20637498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com