gpt4 book ai didi

java - 在 JButton 上设置多个图标

转载 作者:搜寻专家 更新时间:2023-11-01 01:35:32 25 4
gpt4 key购买 nike

我有一个 JButton,我在上面设置了自定义图标。现在我希望它在我将鼠标光标拖到它上面时已经显示的图标之上显示另一个图标,但我不知道该怎么做,因为如果我使用 button.setIcon(icon); 它将替换已经显示的图标。我将如何以尽可能简单的方式执行此操作?

最佳答案

I have a JButton which I have set a custom icon on. Now I want it to display another icon ontop of the one that is already displayed when I drag my mouse cursor over it but I can't figure out how to do it because if I use button.setIcon(icon); it will replace the icon that already is displayed. How would I do this in an as easy way as possible

  • 我想那是关于 JButton.setRolloverIcon(myIcon);

JButton 已经在API 中实现了这些方法

JButton.setIcon(myIcon);
JButton.setRolloverIcon(myIcon);
JButton.setPressedIcon(myIcon);
JButton.setDisabledIcon(myIcon);

关于java - 在 JButton 上设置多个图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16299517/

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