aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Is it possible to change the cursor with onMouseOver... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Is it possible to change the cursor with onMouseOver..." Watch "Is it possible to change the cursor with onMouseOver..." New topic
Author

Is it possible to change the cursor with onMouseOver...

Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 348

Here is my problem. I have a panel which has some lines drawn over it. I need to change the cursor to hand cursor when I move over the lines. I am able to set the cursor as handcursor for the total panel, but it should be changed when I move the mouse over the lines? Is there an event for mouse over? Please help me on this.

Ananth


Ananth Chellathurai [Walk on software]
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Line2D is a Shape and thus has certain properties that are quite useful. One of these is the intersect method, that can be used to see if the mouse intersects a line. You may have to translate the cursor point into a small square for this to work, but it does work.

Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 348

Thanks for your reply. I have got what I want like this,

getPsdGPanel().addMouseMotionListener(new java.awt.event.MouseMotionAdapter()
{
public void mouseMoved(MouseEvent e)
{
psdGPanelMouseMoved(e);
}
});

psdGPanelMouseMoved finds whether there is a line at that e.x and e.y and changes the cursor. Thanks again for your interest shown.

Ananth
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Is it possible to change the cursor with onMouseOver...
 
Similar Threads
waiting cursor for frame
Change the mouse cursor
Swing
waiting cursor
Picking the color under the mouse cursor on a JPanel