static JFrame getFrame(Object o) { if (!(o instanceof Component)) ret null; Component c = (Component) o; while (c != null) { if (c instanceof JFrame) return (JFrame) c; c = c.getParent(); } ret null; }