// can probably be merged with next variant static void disposeWindow(final Window window) { if (window != null) swing { window.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); // call listeners window.dispose(); } } static void disposeWindow(final Component c) { disposeWindow(getWindow(c)); } static void disposeWindow(O o) { if (o != null) disposeWindow((Component) o); }