JavaFX custom control (TextField) not working -
i trying make custom control javafx , scenebuilder 1.1.
i have 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 try open scenebuilder tells me this:
missing types are: [customcomponent]
and gives me chance specify classpath (which doesn't fix problem either).
i tried putting class @ import statement too, this:
<?import libreria.javafx.componentes.componentetextfield.customcomponent?>
but gives classnotfoundexception
.
any ideas why happening?
more information
i have done new project these classes:
and code 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 still have same problem. specify classpath dialog, seems right me have same errors opening scenebuilder.
last information
trying approach solution, tried project under eclipse. result eclipse shows window ok scenebuilder continues errors. hope clue helps.
if has done kind of custom control definition under scene builder, please, tell , give example, extremely helpful our project.
this caused not specifying correct classpath, allows java runtime running scene builder load control classes.
if running eclipse , class has namespace custom.mycontrol
specify bin directory , not custom directory. in maven project need specify target/classes directory.
see example in own project here: https://bitbucket.org/atill/estimate/src/22390a2ca034b55f1916e46435b714e5c489b90e/src/main/resources/projmon/gui/worktree.fxml?at=master
a relative file path created scene builder moving files break class path , need respecify it.
Comments
Post a Comment