0

I am trying to build an UI with custom control. But having trouble to make the scene builder wo work properly with the custom part.

My custom control:

    <?import java.lang.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.image.*?>
    <?import javafx.scene.layout.*?>
    <?import javafx.scene.text.*?>

    <fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="100.0" prefWidth="800.0" type="javafx.scene.layout.AnchorPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
        <children>
    ...other code
        </children>
    </fx:root>

Room.fxml, which use the custom class:

...other code
<?import ag.ctrl.*?>
<?scenebuilder-classpath-element ../../target/classes/ag/ctrl?>
...other code
<BorderPane prefHeight="200.0" prefWidth="200.0"
            BorderPane.alignment="CENTER">
            <top>
                <TeamArea />
            </top>
</BorderPane>

Controller of the custom ui:

package ag.ctrl;
...
public class TeamArea extends AnchorPane {
...
public TeamArea() {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(
                "/ui/TeamArea.fxml"));
        fxmlLoader.setRoot(this);
        fxmlLoader.setController(this);

        try {
            fxmlLoader.load();
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        }
    }
...
}

and all those files' path: TeamArea.fxml: /resource/ui/TeamArea.fxml Room.fxml: /resource/ui/Room.fxml

TeamArea.class: /target/classes/ag/ctrl/TeamArea.class

I try many different approach before.End up with scene builder's class not found error or others. Currently I am having an unresolved class error at the TeamArea Node in scene builder.

Some stupid error must in somewhere...

Could any one help?

MonkeyT
  • 1
  • 1
  • 2

2 Answers2

0

I think you link to the wrong classpath.

Take a look at this thread

Hope that solves your problem.

Community
  • 1
  • 1
Inge
  • 427
  • 7
  • 20
0

Your classpath needs to be:

<?scenebuilder-classpath-element ../../target/classes?>

However, I'm facing the same problem and it doesn't work that way either. Please drop me a comment if you got it working

Michel Jung
  • 2,966
  • 6
  • 31
  • 51