2
votes

The project I am working on is using the JavaFx framework, and therefore we are using fxml files and Scene Builder. I have made a custom control for our application following examples I have found on the web, and it works beautifully. However, we are going to have multiple custom controls with common base functionality. I would like to therefore, inherit the base functionality into a custom control.

What I am trying to do is to create a custom control that extends a custom root control class. This is what the CustomControl.fxml file looks like:

<?import com.custom.CustomRootControl ?>

<fx:root type="CustomRootControl" xmlns:fx="http://javafx.com/fxml">
    /* Add children here... */
</fx:root>

Right now my CustomRootControl class looks like this:

public class CustomRootClass extends Pane {
    /* Customization to be performed */
}

It is skin and bones, and I don't expect to see much in Scene Builder when I open CustomControl.fxml, but the fxml file won't open in Scene Builder. Instead, I get the following error message:

java.io.IOException: javafx.fxml.LoadException: <path_to_CustomControl.fxml>

    ...

Caused by: javafx.fxml.LoadException: <path_to_CustomControl.fxml>

    ...

Caused by: java.lang.ClassNotFoundException: com.custom.CustomRootControl
    at java.lang.ClassLoader.findClass(ClassLoader.java:530)
    ...

Is there a way to do what I am trying to do? And if so, how do I go about doing it?

1
Why on Earth would someone downvote this question. - Mishax

1 Answers

-1
votes

You must insert this in your fxml file

 <?scenebuilder-classpath-element <path_to_CustomControl.jar>?>