Search in sources :

Example 1 with PopupWindow

use of javafx.stage.PopupWindow in project controlsfx by controlsfx.

the class Utils method getWindow.

/**
 * Will return a {@link Window} from an object if any can be found. {@code null}
 * value can be given, the program will then try to find the focused window
 * among those available.
 *
 * @param owner the object whose window is to be found.
 * @return the window of the given object.
 */
public static Window getWindow(Object owner) throws IllegalArgumentException {
    if (owner == null) {
        Window window = null;
        // lets just get the focused stage and show the dialog in there
        List<Window> windows = Window.getWindows();
        for (Window w : windows) {
            window = w;
            if (window.isFocused() && !(window instanceof PopupWindow)) {
                return window;
            }
        }
        return window;
    } else if (owner instanceof Window) {
        return (Window) owner;
    } else if (owner instanceof Node) {
        return ((Node) owner).getScene().getWindow();
    } else {
        // $NON-NLS-1$
        throw new IllegalArgumentException("Unknown owner: " + owner.getClass());
    }
}
Also used : PopupWindow(javafx.stage.PopupWindow) Window(javafx.stage.Window) Node(javafx.scene.Node) PopupWindow(javafx.stage.PopupWindow)

Aggregations

Node (javafx.scene.Node)1 PopupWindow (javafx.stage.PopupWindow)1 Window (javafx.stage.Window)1