void (@NotNull Window window, @NotNull Runnable runnable) { window.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { e.getWindow().removeWindowListener(this); runnable.run(); } }); }