Java tutorial
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.awt.Window; import javax.swing.SwingUtilities; public class Main { static Window getComponentWindow(Component component) { if (component instanceof Window) { return (Window) component; } return SwingUtilities.getWindowAncestor(component); } }