Drag and drop – JavaFX: changes the cursor during drag and drop
•
Java
I want to change the cursor on my node during drag and drop, but the image does not change I call setCursor () in the DragDetectedEventHandler of my node. I also tried calling getparent() Setcursor() and get the same result I have also tried to do this in various other event handlers, such as mouse down and drag Best of all, I change the image after I release the mouse button, but I need to make the image different during dragging Does anyone know how to do it?
private class DragDetectedEventHandler implements EventHandler<MouseEvent> { @Override public void handle(MouseEvent mouseEvent) { System.out.println("Drag Detected"); Dragboard db = startDragAndDrop(TransferMode.MOVE); ClipboardContent content = new ClipboardContent(); content.putString("sample-drag-text"); db.setContent(content); setCursor(_imageCursor); mouseEvent.consume(); } }
Solution
attempt
((Node) mouseEvent.getSource()).setCursor(Cursor.HAND);
If it doesn't work, publish the complete class code containing dragdetectedeventhandler
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码