C
C
Chvalov2016-04-16 06:23:41
Java
Chvalov, 2016-04-16 06:23:41

How to access FX form elements from another class?

Tell me how to get control over the desired form FX8 element from another class.
Or is there nowhere to go beyond the borders of the controller?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Riard Brugekaaim, 2016-04-16
@OLDRihard

You can get it halfway through creating the window. Not from the Stage itself, but from the FXMLLoader. And there you can already get to the elements.

FXMLLoader loader = new FXMLLoader(getClass().getResource("MyGui.fxml"));
Parent root = (Parent)loader.load();
MyController controller = (MyController)loader.getController();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question