简体   繁体   English

拖放事件JavaFX

[英]Drag and Drop event JavaFX

I am trying to create a drag and drop solution between my treetableview and some rectangles in my interface. 我试图在我的treetableview和我的界面中的一些矩形之间创建一个拖放解决方案。 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. 现在我可以从treeTableView中拖出一行,当我将它拖到我的矩形上时,矩形的颜色会发生变化。 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. 但我无法看到这样做的事件。

For the drag target you have four different properties: 对于拖动目标,您有四种不同的属性:

You can use this properties to define a behaviour of the target Node , like: 您可以使用此属性来定义目标Node的行为,例如:

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 
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM