Here's the modified version of amru answer I'm using, this method gives you components of a certain type:
private <T> List<T> getNodesOfType(Pane parent, Class<T> type) { List<T> elements = new ArrayList<>(); for (Node node : parent.getChildren()) { if (node instanceof Pane) { elements.addAll(getNodesOfType((Pane) node, type)); } else if (type.isAssignableFrom(node.getClass())) {
To get all the components:
List<Node> nodes = getNodesOfType(pane, Node.class);
To get only buttons:
List<Button> buttons= getNodesOfType(pane, Button.class);
Utku Γzdemir
source share