I created a JButton which has an image set as an icon representing the button. Now, I've set
我创建了一个JButton,它将图像设置为代表按钮的图标。现在,我已经确定了
setContentAreaFilled(false);
setBorderPainted(false);
setOpaque(false);
the properties which this makes an image-button look nice with no borders or background colors etc.
这使得图像按钮看起来很漂亮,没有边框或背景颜色等属性。
Now the problem is that when I click on the image, it shows no onclick effects of a button, so when there is some background processing involved or some event is bring fired on click of button which takes time to process the request and return something, it gives an impression that the button was not clicked and the user might keep clicking it.
现在问题是,当我点击图像时,它没有显示按钮的onclick效果,所以当涉及一些后台处理或某些事件被点击按钮时触发,这需要时间来处理请求并返回一些东西,它给人的印象是没有点击按钮,用户可能会一直点击它。
How do I make a button which has an icon set with the above mentioned properties and yet I have some control over setting the onpress or onmouseover events.
如何制作一个具有上述属性设置图标的按钮,但我可以控制设置onpress或onmouseover事件。
1 个解决方案
#1
8
I found the answer: setRolloverIcon()
and setPressedIcon()
will do the magic.
我找到了答案:setRolloverIcon()和setPressedIcon()将做出魔术。
#1
8
I found the answer: setRolloverIcon()
and setPressedIcon()
will do the magic.
我找到了答案:setRolloverIcon()和setPressedIcon()将做出魔术。