William Estupina
William Estupina

Reputation: 55

Drag and Drop event JavaFX

I am trying to create a drag and drop solution between my treetableview and some rectangles in my interface. For now I am able to drag a row from my treeTableView and when I drag it over my rectangle, then the color of the rectangle change. But now I would like to be notified when the drag is not over anymore, so that i can change back the color on my rectangle. But I am not able to see an event doing this.

Upvotes: 1

Views: 533

Answers (1)

DVarga
DVarga

Reputation: 21829

For the drag target you have four different properties:

You can use this properties to define a behaviour of the target Node, like:

Rectangle rect = new Rectangle();
rect.setOnDragEntered(value -> {
    // Set the drag-over color here
});

rect.setOnDragExited(value -> {
    // Reset the original color here
});

rect.setOnDragDropped(value -> { 
    // Reset the original color here 
});

Upvotes: 1

Related Questions