wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to do a Mouseover.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to do a Mouseover.." Watch "How to do a Mouseover.." New topic
Author

How to do a Mouseover..

Rocky Summers
Ranch Hand

Joined: Nov 07, 2003
Posts: 66
I'm curious... is there any way i can add a "Mouseover" to a JLabel so that when the mouse is over it, the cursor changes to a hand-cursor?
Thanks,
Rock
Lalit K Kumar
Ranch Hand

Joined: Jan 29, 2004
Posts: 32
hi,
I think you can add a "mouseover" on a jlabel. To do so you will have to implement "MouseListener" class.Then to the respective label add the listener (.addMouseListener) and implement the required methods ("mouseOver" in your case).
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Ummm... actually the interface you want to look at is MouseMotionListener... and the method you'll want to use is mouseMoved(). You could also try setting a boolean in mouseEntered() and unsetting it in mouseExited() of the MouseListener interface.

You could also use a JButton instead of a JLabel and use the built in methods - setRolloverEnabled(), setRolloverIcon(), etc.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Brian Pipa
Ranch Hand

Joined: Sep 29, 2003
Posts: 299
You can do this. Add a mouseListener to a JLabel and change the cursor on mouseEntered and mouseExited.
I have a custom class that does just this - if anyone wants to see the code, let me know.
Brian


My Java Freeware:<br />MACCC - <a href="http://maccc.pipasoft.com" target="_blank" rel="nofollow">http://maccc.pipasoft.com</a><br />Nator - <a href="http://nator.pipasoft.com" target="_blank" rel="nofollow">http://nator.pipasoft.com</a>
Rocky Summers
Ranch Hand

Joined: Nov 07, 2003
Posts: 66
Brian I do!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to do a Mouseover..
 
Similar Threads
OnMouseOver in Ajax
Prototype 'mouseover' Event
WA #1.....word association
Mouseover on the whole td elemet
Problem to submit form using javascript in struts