The objective is to use drag and drop on a treeView to move the nodes on itself.
I have seen several examples where the events are handled in a redefined TreeCell, but only the detected event is triggered.
This is my code:
public class TreeCellImpl extends TreeCell<TreeItemContent> {
public TreeCellImpl() {
setOnDragEntered(e -> {
System.out.println(" Entered ");
e.consume();
});
setOnDragDetected(e -> {
System.out.println(" Detected ");
startDragAndDrop(TransferMode.MOVE);
e.consume();
});
setOnDragDone(e -> {
System.out.println(" Done ");
e.consume();
});
setOnDragDropped(e -> {
System.out.println(" Dropped ");
e.setDropCompleted(true);
e.consume();
});
setOnDragExited(e -> {
System.out.println(" Exited ");
e.consume();
});
setOnDragOver(e -> {
System.out.println(" Over ");
e.consume();
});
}
}
Where i wrong ?
It seems the event handlers are not triggered until you put some content to
Dragboard
:You may also choose to use the other type of drag-n-drop mechanism described in MouseEvent. I.e. MouseDragEvent.