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);
}
});