How can I cancel a drag and drop operation in Java / Swing programmatically?

I'm just wondering if I can undo the drag and drop operation in Java / Swing programmatically? Thus, the effect will be similar to the way the user pressed the "ESC" key?

I was expecting a DragSourceDragEvent or DragSourceContext to have a cancelDrag() method similar to DropTargetDragEvent , which has acceptDrag() and rejectDrag() methods (both of which fail to do what I want).

Am I missing something?

+4
source share
1 answer

Confirmed I tried several ways to do this and nothing worked. I also tried using the Robot class to hit escape :)

It appears that it is currently not possible to undo this using the current API.

+2
source

Source: https://habr.com/ru/post/1303752/


All Articles