static Window getWindow(Object o) { if (!o instanceof Component) ret null; ret swing(() -> { Component c = cast o; while (c != null) { if (c cast Window) ret c; c = c.getParent(); } null; }); }