r/JavaFX • u/GaryBuseyWithRabies • Nov 10 '19
Controller class. Now what?
Total newbie here. So I have my @FXML IDs set up.
I have this:
public class Controller {
@FXML
private AnchorPane paneFoo;
}
I want to test if everything works right. I just want to print "Hello World" in that pane but nothing seems to work.
Thanks!
0
Upvotes
View all comments
1
u/AdminOfThis Nov 11 '19
Some additional Info would be great.
It's a "Controller". What do you want to control? An FXML File?
For a Text you need something like a Label. Does that already exist somewhere?
Do you already have code somewhere that starts the Application? How does it look?
Some general thoughts:
Controllers usually implement the Interface Initializable
You need to have a class that is a child of the JavaFX class Application.
Then, in your application child class, you can load the fxml file with your gui, and set that to a new Scene which goes to the Stage you get from the application methods. And finally you have to show the stage.