📜  java jbutton hover - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:20.054000             🧑  作者: Mango

代码示例1
JButton b = new JButton();
b.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent e) {
    JButton j = (JButton) e.getSource();
    j.setBackground(Color.Red);
}
public void mouseExited(java.awt.event.MouseEvent e) {
    JButton j = (JButton) e.getSource();
    j.setBackground(Color.Green);
}
});