Get outermost container of a JavaFX node - Java JavaFX

Java examples for JavaFX:Node

Description

Get outermost container of a JavaFX node

Demo Code

/*******************************************************************************
 * Copyright (c) 2015-2016 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
import javafx.geometry.Bounds;
import javafx.scene.Node;
import javafx.scene.control.Dialog;

public class Main{
    /** Get outermost container of a node
     *  @param node JFX Node//from  w  w w. j  a  v  a 2 s  .co  m
     *  @return Outermost container
     */
    public static Node getContainer(final Node node) {
        Node container = node;
        while (container.getParent() != null)
            container = container.getParent();
        return container;
    }
}

Related Tutorials