'Change drag&drop cursor on macOS with JavaFX

How can i change the cursor on macOS with JavaFX when i drag an item?

I have tried to use the function pane.setCursor() that change the cursor, but when I drag an item I see a white paper behind the cursor.

//drag detection for node dragging
pane.setOnDragDetected ( event -> {
    ImageCursor cursor = 
        new ImageCursor(new Image("/cursor.png"));

    pane.setCursor(cursor); 
});

Example:

  1. Before drag purple line
  2. Drag line
  3. After drag

Drag and drop with custom cursor:

drag and drop with custom cursor

I have tried to run the code on Ubuntu 19 and Windows 10, but this problem isn't there.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source