Skip to content
Advertisement

Tag: mouse-cursor

Retrieve mouse position in JavaFX without event

I want to retrieve the x and y coordinates of the current mouse position before showing a stage. So far, the only way I found to get the mouse position in JavaFX is within a MouseEvent, which does not apply to my situation. Furthermore, I found the possibility to retrieve the position via java.awt.MouseInfo. This, however, I think is a

JavaFX 2 set/get cursor position

How can I set/get the cursor’s position in JavaFX 2? I tired googling the answer but found nothing useful. All I can do is setting the cursor’s style. Answer You can use robot for that purpose: AWT robot: http://docs.oracle.com/javase/1.5.0/docs/api/java/awt/Robot.html or glass robot: com.sun.glass.ui.Robot; which could be created with: com.sun.glass.ui.Application.GetApplication().createRobot(); To get the cursor position, see other post for this question

How to change the cursor type

This question is related to the previous post. How to save file and read alt text http://freeimagehosting.net/image.php?dc73c3bb33.jpg How can I change the cursor to “Hand” only when the mouse pointed on grid which is not Null (contained images)? So far the cursor turn to “Hand” all over the grids (null or not null). Answer This should have the desired effect:

Advertisement