code: public static Window getWindowForComponent(Component parentComponent) throws HeadlessException {
  		if (parentComponent == null)
  			return JOptionPane.getRootFrame();
  		if (parentComponent instanceof Frame || parentComponent instanceof Dialog)
  			return (Window) parentComponent;
  		return getWindowForComponent(parentComponent.getParent());
  	}
docs: <p>
  --jh-- This method is copied from JOptionPane. I'm still trying to figure
  out why they chose to have a static method with package visibility for
  this one instead of just making it public.
  </p>
  
  Returns the specified component's toplevel <code>Frame</code> or
  <code>Dialog</code>.
  
  @param parentComponent the <code>Component</code> to check for a
  <code>Frame</code> or <code>Dialog</code>
  @return the <code>Frame</code> or <code>Dialog</code> that contains
  the component, or the default frame if the component is <code>null</code>,
  or does not have a valid <code>Frame</code> or <code>Dialog</code>
  parent
  @exception HeadlessException if
  <code>GraphicsEnvironment.isHeadless</code> returns <code>true</code>
  @see java.awt.GraphicsEnvironment#isHeadless