Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get FXML file nodes using java code

Tags:

javafx

fxml

How to get elements or nodes from FXML file using Java, I know the way by using initialization or by setting controller class in FxmL . But I need to do it without any controller. I want to access the nodes inside the fxml file using.

My FXML COde:

HBox fx:id="hbx" id="hbx" alignment="CENTER_RIGHT" prefHeight="100.0"
prefWidth="200.0" BorderPane.alignment="CENTER"

My java Code

System.out.println(par.lookupAll("hbx"));

See my Code above, could you give me a hint?

like image 843
GowthamIyer Avatar asked Jan 11 '23 20:01

GowthamIyer


1 Answers

After loading the FXML file, you can use Node#lookup():

Node node = fxmlParentPane.lookup("#nodeId");
like image 92
Uluk Biy Avatar answered Feb 27 '23 12:02

Uluk Biy