I am trying to drag tags onto each other.
I have a list of labels called starsAndBars, and each shortcut calls this on it since it is created:
private void giveDragAndDropProperties(Label label) {
label.setOnDragDetected(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
System.out.println("Drag and drop started!");
Dragboard db = label.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
int index = starsAndBars.indexOf(label);
content.putString("test");
db.setContent(content);
event.consume();
}
});
label.setOnDragEntered(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
System.out.println("drag entered!");
}
});
label.setOnDragExited(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
System.out.println("drag left!");
}
});
label.setOnDragDropped(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
System.out.println("Drop occurred!");
}
});
}
When I try to perform a drag operation, this is what I see:
Drag and drop started!
drag entered!
drag left!
drag entered!
<I release the mouse here>
drag left!
The onDragDropped event is never logged, as far as I can tell. What am I doing wrong? I can say that each shortcut has drag and drop event handlers, since they log βinputβ and βoutputβ events. This is the only piece of code that is associated with Drag and Drop event handlers, so it must first be consumed by something else.
All of these labels are in the HBox, which is inside the ScrollPane, if that matters.
: HBox, - . setOnDragDropped , .
setOnDragDetected setOnDragDropped, (http://docs.oracle.com/javafx/2/drag_drop/jfxpub-drag_drop.htm), , .
2: , , , , - ( ). , . .
, ?