0

I'm working on going through a tutorial to learn about JavaFX with Scene Builder and I use IntelliJ IDEA instead of Eclipse, which is what the tutorial used. I made a Javascript project in IDEA and it made my src, projectX, Controller.java, Main.java, and projectX.fxml files for me.

I have the project open in Scene Builder now and I added a controller class to the anchor pane, which it autocompletes for me because it recognizes that I have a controller class and it looks correct.
However, when I go back to my .fxml file, it has my controller label in red as an error, and says No controller specified for top level element. It also says Cannot resolve class or package projectX.
What the hell am I supposed to do differently? I followed the tutorial exactly...

The project file structure is as follows:

ProjectX > src > ProjectX (package) > Controller.java > Main.Java > ProjectX.fxml

Here's the error in the .fxml file: http://gyazo.com/ad16dc55cc3ba59ebf9e60e2497f03af

And in Scene Builder, this is what I typed in "Controller class": Main.ProjectBonify.Controller ALSO TRIED: ProjectBonify.Controller
Neither work.

Thanks in advance.

Mazzone
  • 318
  • 1
  • 4
  • 20
  • I think to get help, you will need to update your question to include all of your source code (Java and FXML) and the directory structure that you use for it (i.e. paste the source code for an [mcve](http://stackoverflow.com/help/mcve) into your question). – jewelsea May 08 '15 at 22:26
  • Java naming conventions is that [package names only contain lower case letters](https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html), so referencing your class as `Main.ProjectBonify.Controller` seems weird. Also that name doesn't seem valid as it does not match the `ProjectX` package structure supplied in your question. – jewelsea May 08 '15 at 22:26
  • What is the meaning of this line in your question: "ProjectX > src > ProjectX (package) > Controller.java > Main.Java > ProjectX.fxml"? Is it that Controller.java, Main.java and ProjectX.fxml are all under the `ProjectX/src/ProjectX` directory? Also the error message mentions "projectX" rather than "ProjectX", so the case doesn't seem to match either. – jewelsea May 08 '15 at 22:28

1 Answers1

0

The error message means that the "fx:controller" isn't found.

Here are some examples of what worked for me:

fx:controller="stockmanager.FXMLDocumentController" fx:controller="simplefmxlexample.FXMLDocumentController"

stockmanager and simplefmxlexample are package names

FXMLDocumentController is the class name of the controller

You can also set this in Scene Builder, see: JavaFX scene builder 2: controller class

Charles Knell
  • 342
  • 1
  • 7