Does anyone with IntelliJ & NetBeans experience know, if IntelliJ has some similar feature as for NetBeans "Make controller" when right clicking the corresponding FXML file?
I think it is pretty important since it updates, if I have added something new (a FXID for example), and if I deleted it and such - and also places it in the correct place by itself.
I know you, in Scene Builder, can go to "View -> Show Sample Controller Skeleton", but this is just not enough automation, especially not from a Jetbrains IDE.
This also means that the following link is not an answer: how to do netbeans'"make controller" in intellij idea
[]
Modify the Controller Skeleton and your Main Application as needed. Run the program in Idea. If you make subsequent changes to the FXML, use View | Show Sample Skeleton again to generate new Controller code, then manually copy and paste in the bits you want into your controller.
Explanation: fx:controller is used to including controller class.
It is also possible to assign the controller class directly from the FXML file. In order to do that, you should first open your FXML file and add the following code on the first line of the file right after declarations. Example: Since my controller is inside the package name “view”, my fx: controller = “view.
If you use Javaru's solution then created fields will be public and without @FXML annotations.
To change it go to: File | Settings | Editor | Code Style | Java | Code Generation | Default Visibility - choose Escalate or Private, and check "use external annotations" at the bottom.
Second solution: open fxml file in scene builder set the controller class in controller section at left bottom part of window. Go to: view | show sample controller skeleton and copy controller class code.
It is my first post, hope I've helped. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With