void (final @Nullable DnDTarget target, final @Nullable JComponent targetComponent) { Runnable cleanup = () -> { if (shouldCancelCurrentDnDOperation(target, targetComponent)) { myLastProcessedOverComponent = null; myCurrentDragContext = null; resetEvents("cleanup"); } }; if (ApplicationManager.getApplication().isDispatchThread()) { cleanup.run(); } else { SwingUtilities.invokeLater(cleanup); } }