Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ, is it possible to "Make controller" as in NetBeans?

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

[Menu in Netbeans, showing the "Make controller" feature]

Menu in IntelliJ, showing nothing about controllers

like image 736
ThomasBear Avatar asked Nov 10 '17 14:11

ThomasBear


People also ask

How to generate controller in intellij?

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.

Which interface should be used with controller class?

Explanation: fx:controller is used to including controller class.

How do I specify a controller in FXML file?

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.


1 Answers

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. :)

like image 106
Mcin Avatar answered Sep 29 '22 15:09

Mcin