public static Window getWindowForComponent(Component comp) {
		while (true) {
			if (comp == null) {
				return JOptionPane.getRootFrame();
			}
			if (comp instanceof Frame || comp instanceof Dialog) {
				return (Window) comp;
			}
			comp = comp.getParent();
		}
	}