Javafx-8 – how do I set up the controller in the scene builder?

I want to use scene builder for JavaFX applications I have a software package called testpac, which contains my folder, as shown in Figure 1;

I have an fxml file and its controller in the view folder Now, I don't know what must be used in the controller box of scene builder The contents of the view folder are shown in Figure 2

Solution

You only need to specify the fully qualified class name, packagename ClassName. Therefore, if I understand your project structure correctly, your controller class is scaterchartcontroller1, which is located in a directory called testpac In the package of view1,2 So your FX: controller attribute should have the value FX: controller = "testpac. View. Scaterchartcontroller"

In scene builder, you can set it in the controller pane in the lower left corner of the screen (expand it if necessary):

Footnote:

>You should follow proper naming conventions, so all class names should start with uppercase letters According to standard conventions, scaterchartcontroller is not the correct class name Similarly, package names should be all lowercase, so "package named testpac" also violates the Convention. > You can see the package name from the first line of code I assume you have a package name view, so the first line of code in the controller class will be

package testPac.view ;

If the package is different, modify the FX: controller property accordingly

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>