I am using Netbeans and Scenebuilder to create a JavaFX project. I realized that Scenebuilder does not have a date picker component so I downloaded the jfxtras and added the library to my classpath. I used the following code to add the CalendarTextField Object to my FXML file:

 <?import jfxtras.labs.scene.control.*?> 

 <CalendarTextField fx:id="setupdate" prefWidth="200.0" showTime="true"  GridPane.columnIndex="3" GridPane.rowIndex="8" />

It appeared to have worked ok, however, when I opened my FXML file in Scenebuilder I am getting the following error:

    fxml:99: error: 
    javafx.fxml.LoadException: Element does not define a default property.

I am not sure what this means.

有帮助吗?

解决方案

Java 8 DatePicker

Use Java 8 + SceneBuilder 2, it has a DatePicker.

Both are early access (especially SceneBuilder 2). Don't expect much in the way of SceneBuilder 2 stability for a little while, it's implementation is currently pretty rough and not as polished as SceneBuilder 1.1.


jfxtras and fxml

With regards to the use of jfxtras controls in SceneBuilder 1.1, my guess is that it is just not supported.

In order to build the jfxtras controls for Java 7, it was necessary for the jfxtras developers to make use of private APIs as feature complete public APIs for building custom controls are not available in Java 8. Usage of private APIs may cause compatibility issues with different SceneBuilder versions as it ties the control binaries to only work with certain JavaFX versions (as backward compatibility of private JavaFX apis is not guaranteed in new Java versions).

Also, the jfxtras developers may not have implemented the builder classes required to make their controls work with FXML. This would seem to be the case, as lack of an appropriate builder is what generates the error: javafx.fxml.LoadException: Element does not define a default property.


Implementing your own builder

You can read more about builders and fxml in an Introduction to FXML. You could implement a builder for the jfxtras CalendarTextField if you wish (I will not write one in this answer though). If you did implement an appropriate builder, there is a reasonable chance that you would then be able to use the control in FXML used by SceneBuilder 1.1.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top