Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javafx 8 how to make mouse cursor invisible?

I am making a 2D shooting game on Javafx 8 and I would like to be able to make the cursor invisible so that I can replace it with crosshairs.

Is there anyway to make the mouse cursor invisible when it is on the scene?

like image 253
gameCoder95 Avatar asked Dec 30 '14 23:12

gameCoder95


1 Answers

To change your cursor, you'd use the scene.setCursor(String) method.

To change image

Using a reference to your current scene, pass in Cursor.cursor("url") to setCursor:

scene.setCursor(Cursor.cursor("url"));

To remove the cursor

Using a reference to your current scene, pass in Cursor.NONE to setCursor:

scene.setCursor(Cursor.NONE);

You also might be interested in the Cursor.CROSSHAIR value

like image 160
Vince Avatar answered Sep 28 '22 05:09

Vince