Scene Builder Custom Control ClassNotFoundException
970454Oct 24 2012 — edited Apr 21 2013I've been having trouble loading custom control classes into Scene Builder. I made an fxml file that has uses CustomPane, which extends Pane, and it has a CustomButton child. The xml code is here:
<?xml version="1.0" encoding="UTF-8"?>
<?import control.CustomPane?>
<?import control.CustomButton?>
<CustomPane prefHeight="100.0" prefWidth="100.0" xmlns:fx="http://javafx.com/fxml" fx:controller="control.CustomPane$Controller">
<children>
<CustomButton fx:id="customD" layoutX="20.0" layoutY="20.0" mnemonicParsing="false" text="MyButton" />
</children>
</CustomPane>
The controller for CustomPane.fxml is owned by CustomPane:
public class CustomPane extends Pane {
private Controller controller;
private void setController(Controller controller) {
this.controller = controller;
}
public static CustomPane makeCopy() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(CustomPane.class.getResource("/display/fxml/CustomPane.fxml"));
try {
CustomPane c = (CustomPane) loader.load();
c.setController((Controller) loader.getController());
return c;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static class Controller {
@FXML
private CustomButton customButton;
}
}
This code works when not using Scene Builder. When I try using Scene Builder I get a ClassNotFoundException stating that control.customPane can't be found. If I remove the import statements, I get the set up classpath dialog, but when I try to add my "control" folder, CustomButton and CustomPane still cannot be found. Any suggestions? Am I missing something in my setup of Scene Builder?