lookup Within JavaFX Node - Java JavaFX

Java examples for JavaFX:Node

Description

lookup Within JavaFX Node

Demo Code


//package com.java2s;
import javafx.scene.Node;

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T lookupWithinNode(final Node parent,
            final String query, final Class<T> clazz) {
        for (Node node : parent.lookupAll(query)) {
            if (node.getClass().isAssignableFrom(clazz)) {
                return (T) node;
            }/*www . jav  a2 s .  c o  m*/
        }
        throw new IllegalArgumentException("Parent " + parent
                + " doesn't contain node matching query " + query);
    }
}

Related Tutorials