如何在鼠标输入/鼠标退出时更改按钮的图标图像? [英] How to change icon image of button on mouse entered/mouse exit?
本文介绍了如何在鼠标输入/鼠标退出时更改按钮的图标图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改鼠标输入和鼠标退出时按钮的图标图像。
I want to change icon image of an Button on Mouse Entered and Mouse Exited.
private void jButton1MouseEntered(java.awt.event.MouseEvent evt) {
this.jButton1.setBackground(Color.red);
this.jButton1.setForeground(Color.BLUE)
} ;
private void jButton1MouseExited(java.awt.event.MouseEvent evt) {
this.jButton1.setBackground(Color.lightGray);
this.jButton1.setForeground(Color.BLACK);
}
请建议如何更改图标图像。
Please suggest how to change icon image.
推荐答案
参见 setRolloverIcon(Icon)
(不需要 MouseListener
)。
这篇关于如何在鼠标输入/鼠标退出时更改按钮的图标图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文