I want to access all the nodes that are contained in a TitledPane
for which I do a loop:
for ( Node panel : panelTitulado.getChildren()){
System.out.println ("Nodo: " + panel.toString());
}
This procedure works for containers like VBox but not TitledPane
because the property does not exist getChildren()
. Is there a property that allows access to the content to know all the nodes inside?
You should use
getContent()
, for example:It is important to cast the type of container that is regularly
AnchorPane
:In this way you can obtain the information of the nodes contained within the
TitledPane
If you want to access all the nodes of a
TitledPane
, you must first get the contents of it, then perform a get tocasting
theNode
specific type oflayout
set and invoke on itgetChildren
.Suppose we have created the content of our
TitlePane
like this:Now, the reverse process would be:
Note that to get the nodes of myLayout I use the forEach method together with a lambda expression enabled as of java version 8.