I am trying to make a custom control with JavaFX and SceneBuilder 1.1.
I have this code:
FXML
<?import libreria.javaFX.componentes.componenteTextField.*?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml">
<children>
<CustomComponent fx:id="pastaTxt" layoutX="69.0" layoutY="87.0" prefWidth="200.0" />
</children>
</AnchorPane>
CustomComponent.java
package libreria.javaFX.componentes.componenteTextField;
import javafx.scene.control.TextField;
public class CustomComponent extends TextField {
public CustomComponent() {
super();
// TODO Auto-generated constructor stub
}
public CustomComponent(String arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
}
When I try to open it from SceneBuilder it tells me this:
Missing types are: [CustomComponent]
and it gives me the chance to specify the Classpath (which doesn't fix the problem either).
I tried putting the class at the import statement too, like this:
<?import libreria.javaFX.componentes.componenteTextField.CustomComponent?>
But it gives a ClassNotFoundException
.
Any ideas about why is this happening?
MORE INFORMATION
I have done a new project with just these classes:
And the code is as follows:
CustomControl.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import custom.CustomControl?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?scenebuilder-classpath-element ../../bin/custom?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml">
<children>
<CustomControl layoutX="51.0" layoutY="100.0" prefWidth="200.0" />
</children>
</AnchorPane>
CustomControl.java
package custom;
import javafx.scene.control.TextField;
public class CustomControl extends TextField {
public CustomControl() {
super();
}
public CustomControl(String arg0) {
super(arg0);
}
}
And I still have the same problem. I specify the classpath with the dialog, everything seems right to me but I have the same errors opening the SceneBuilder.
LAST INFORMATION
Trying to approach to the solution, we tried this project under Eclipse. The result is that Eclipse shows the window ok but SceneBuilder continues with those errors. I hope this clue helps.
If anyone has done this kind of custom control definition under Scene Builder, please, tell us and give us an example, it will be extremely helpful for our project.