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