JavaFX8 startFullDrag()无效
我想通过拖放连接两个圆JavaFX8 startFullDrag()无效,java,javafx,drag-and-drop,Java,Javafx,Drag And Drop,我想通过拖放连接两个圆 Pane p = new Pane(); Circle c1 = new Circle(5); c1.relocate(10,10); c1.addEventFilter(MouseEvent.DRAG_DETECTED, e -> { c1.startFullDrag(); System.out.println("started"); }); Circle c2 = new Circle(5); c2.relocate(40,40); c2.a
Pane p = new Pane();
Circle c1 = new Circle(5);
c1.relocate(10,10);
c1.addEventFilter(MouseEvent.DRAG_DETECTED, e -> {
c1.startFullDrag();
System.out.println("started");
});
Circle c2 = new Circle(5);
c2.relocate(40,40);
c2.addEventFilter(DragEvent.ANY, e -> System.out.println("any") );
c2.addEventFilter(DragEvent.DRAG_ENTERED, e -> System.out.println("entered") );
p.getChildren().addAll(c1, c2);
我就是这么做的。从左圆圈
c1
拖放到右圆圈c2
时,检测到的拖放事件将起作用。
但输入的DragEvent.ANY
或DragEvent.DRAG\u将不会触发
我还尝试在DRAG\u中使用鼠标事件,但这也没有改变任何事情。
我还尝试使用setondragenter(EventHandler)
和addEventHandler(EventType,EventHandler)
代替addEventFilter(EventType,EventHandler)
,但都不起作用
为什么c2
没有收到任何DragEvent
s?启动fulldrag()
将触发MouseDragEvents,但不会触发DragEvents
替换添加的过滤器(DragEvent.DRAG_输入,…)使用addEventFilter(MouseDragEvent.DRAG_输入,…)进行编码>代码>