Skip to content
Advertisement

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.

Advertisement

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 about java.awt.MouseInfo

Advertisement