JavaFX custom control (TextField) not working

十年热恋 提交于 2019-11-30 12:44:55

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: https://bitbucket.org/atill/estimate/src/22390a2ca034b55f1916e46435b714e5c489b90e/src/main/resources/projmon/gui/workTree.fxml?at=master

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.

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:)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!