I want to use sceneBuilder
for a javaFx
application. I have a Package
that is called testPac
and inside that I have the folders as has been presented in figure 1;
I have one fxml
file and its controller
inside the view
folder.
now, I don't know what I must use inside the controller box in sceneBuilder
.
the content of view
folder according to figure 2.
There are two ways to set a controller for an FXML file. The first way to set a controller is to specify it inside the FXML file. The second way is to set an instance of the controller class on the FXMLLoader instance used to load the FXML document.
JavaFX controller works based on MVC(Model-View-Controller) JavaFX MVC can be achieved by FXML (EFF-ects eXtended Markup Language). FXML is an XML based language used to develop the graphical user interfaces for JavaFX applications as in the HTML.
You just need to specify the fully-qualified classname, i.e. packagename.ClassName
. So, if I understand your project structure correctly, your controller class is scaterChartController
1 and it is in a package called testPac.view
1,2. So your fx:controller
attribute should have the value fx:controller = "testPac.view.scaterChartController"
.
In SceneBuilder you can set this in the "Controller" pane which is in the bottom left of the screen (expand it if necessary):
scaterChartController
is not a proper class name according to the standard convention. Similarly, package names should be all lower case, so "a package called testPac
" also violates the convention.The package name is evident from the first line of code. I am assuming you have a package name of view
, so the first line of code in the controller class will be
package testPac.view ;
Modify the fx:controller
attribute accordingly if the package is different to that.
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