Changing image on JButton when mouse is over it
- From: Brian <mail@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 20:53:55 +0200
Hi all
I'm trying to get a JButton to change the image when the mouse is over
it, but I can't get it to work.
The code:
ImageIcon icon = new ImageIcon("images/MRButton.png"");
JButton MRButton = new JButton(icon);
button.addMouseListener(new MouseListener(){
public void mouseEntered(MouseEvent arg0) {
//I have tried this - but i don't work :(
icon = new ImageIcon("lommeregner/images/MRButton_over.png");
}
public void mouseExited(MouseEvent arg0) {
//some code here ...
}
}
Can someone give me a hint to solve this little problem ?
/Brian
.
- Prev by Date: Re: Forums
- Next by Date: Re: Singly Linked LIst and Objects Newbie Question
- Previous by thread: do I need "volatile" for HashMap? when I apply ReentrantReadWriteLock on it.
- Next by thread: Re: ONLINE CODING EVENT AT INNOVISION@NSIT
- Index(es):