JavaFX custom control (TextField) not working


I am trying to make a custom control with JavaFX and SceneBuilder 1.1.

I have this code:


<?import libreria.javaFX.componentes.componenteTextField.*?>

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="">
    <CustomComponent fx:id="pastaTxt" layoutX="69.0" layoutY="87.0" prefWidth="200.0" />

package libreria.javaFX.componentes.componenteTextField;

import javafx.scene.control.TextField;

public class CustomComponent extends TextField {

public CustomComponent() {
    // TODO Auto-generated constructor stub

public CustomComponent(String 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?


I have done a new project with just these classes:

enter image description here

And the code is as follows:


<?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="">
    <CustomControl layoutX="51.0" layoutY="100.0" prefWidth="200.0" />

package custom;

import javafx.scene.control.TextField;

public class CustomControl extends TextField {

    public CustomControl() {

public CustomControl(String 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.


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.

5/24/2013 7:34:11 AM

Accepted Answer

This is caused by not specifying the correct classpath, which allows the java runtime running scene builder to load the control classes.

If you are running eclipse and your class has the namespace custom.MyControl then specify the bin directory and not the custom directory. In a maven project you need to specify the target/classes directory.

See an example in my own project here:

A relative file path is often created by scene builder so moving files will break the class path and you will need to respecify it.

5/24/2013 8:50:17 PM

maybe it is late but I would like to tell what I did. I am using J8, Eclipse IDE and Scenebuilder 2.0.

1) On Eclipse IDE, open Navigator view from Window->Show View > Navigator 2) On your project, right click and select "Properties" on the class you want to see on SB (Scene Builder) . Verify the location of the generated class from the Resource section. For example you shuould see the location as in the following. /TableViewDemo/bin/com/company/jfx8/example/fxmltableview/FormattedTableCellFactory.class

3) Copy this address and add fxml such as

<?scenebuilder-classpath-element ../../../../TableViewDemo/bin/com/company/jfx8/example/fxmltableview/FormattedTableCellFactory.class?> 

4) Then save it and enjoy your work:)

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow