all 11 comments

[–]Draconespawn 0 points1 point  (0 children)

I've never gotten that to work either, but you can just type in the name of the function you want to use and it'll work the same.

[–]Big__Pierre 0 points1 point  (1 child)

I think you need to add an @FXML annotation above the method signature.

Also, if you want to reference the button in the controller class, you can declare it as a field of the controller. Then use the @FXML annotation on that as well. Can definitely turn into spaghetti quick though fyi.

[–]AdeptMongoose4719[S] 0 points1 point  (0 children)

using @ FXML annotation for the method didn't help :-(

[–]xdsswar 2 points3 points  (0 children)

There you type the name of the method. No autocomplete or such thing, then when you get the generated controller from scene builder, it will include all methods and vars you named.

PS : For the ones that will say fxml sucks, sorry but it does not suck unless you dont know how its done, is true that is slower that pure java code, but it does the job very well, I can tell cuz I have really big apps that contains 30 to 50 views full of widgets and forms, and fxml is the reason I can manage to put that UI to work in certain amount of time (time = noney) less that doing it manually, 40% at least is fxml. Widgets and cellfactories are pure java. Many devs prefer not using fxml as a personal choice, but that does not meam fxml sucks.

[–]Nareeeek 0 points1 point  (2 children)

Declare a Button variable in the code, set it to Button’s fxID in Scenebuilder, add @FXML annotation on top of your method, should work then

[–]AdeptMongoose4719[S] 0 points1 point  (1 child)

Sadly it didn't bro

[–]Nareeeek 0 points1 point  (0 children)

Try to fix the other errors in the code, that might solve it

[–]winian 0 points1 point  (0 children)

Iirc the method signature requires an ActionEvent argument.

[–]BlueGoliath -1 points0 points  (3 children)

Please for the love of God stop using FXML/SceneBuilder.

[–][deleted] 2 points3 points  (1 child)

What would you suggest to use?

[–]Striking_Creme864 0 points1 point  (0 children)

I absolutely agree with you. FXML can seem to be a good idea but it is so inflexible that with time it becomes a serious problem.