void () { LOG.assertTrue(EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only"); for (Runnable runnable : myDisposeActions) { runnable.run(); } myDisposeActions.clear(); Runnable disposer = () -> { Disposer.dispose(myDialog); myProject = null; SwingUtilities.invokeLater(() -> { if (myDialog.getRootPane() != null) { myDialog.remove(myDialog.getRootPane()); } }); }; EdtInvocationManager.invokeLaterIfNeeded(disposer); }