I'm very new to JavaFX
and I'm having problem using my custom class in FXML
. The console keeps giving me this exception when trying to load main.fxml
:
... 1 more
Caused by: java.lang.ClassNotFoundException: sample.View$BoardPane
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
...
I created BoardPane
class as a subclass of FlowPane
in package sample.View
and referred to it in my FXML as the following:
<?import sample.View.BoardPane?>
...
<TitledPane expanded="true" collapsible="false" text="BoardPane" fx:id="centerTitledPane">
<BoardPane fx:id="mechoBoardPane"/>
</TitledPane>
...
and the project structure looks like this:
- resources
- fxml
- main.fxml
- fxml
- ...
- src
- ...
- sample
- ...
- View
- BoardPane
Can anyone please help me on this? I've been searching for some time and haven't found any explanation.
The package name "View" must be lower case. In your project, as well as in the fxml.
For more details see the method loadType of FXMLLoader.class: