javafxscenebuildergluonjfoenixfontawesomefx

Load custom components in scenebuilder 17


We are working on Javafx project which was working fine on Java8. Recently, We have updated the project with Java17. We are able to resolve the issues for the IDEA.

Seems like after Java 9+ they have strictly encapsulated all classes. To use this we have to use "export" "open" keywords in vm options or define "ALL-UNNAMED" in the compile runtime.

This is running perfectly on IDEA. Now, We are trying to load fxml files in scene builder but scenebuilder unable to find out these classes. We have added all required jar files to scenebuilder but still unable to load the FXML files.

Following errors scenebuilder showing:

java.lang.ClassNotFoundException: com.sun.javafx.scene.TreeShowingExpression

Libraries we are using:

jfoenix.jar. fx_progress_circle.jar. fontawesomefx.jar

We are getting issues on the JFX views on JFXCheckbox, JFXRadioButton, JFXSpinner etc.

We have tried every possible solution, but couldn't solve it.

Any help would be appreciated. thanks.


Solution

  • For an example of creating a custom component library and importing it into SceneBuilder (with sample code and screenshots) see:


    As noted in comments, currently with recent versions of jfoenix and SceneBuilder, even if you perform the steps in this post:

    JFXSpinner, JTextfield does not seems to work on scenebuilder version 17. There is probably more controls that are not working too.

    If you follow these steps and find obvious bugs, then you may wish to report these to the jfoenix team.


    Importing jfoenix and fontawesomefx libraries:

    1. Click the Settings Icon in the Scene Builder Library Panel
    2. Choose JAR/FXML Manager
    3. Choose Search Repositories
    4. Search for jfoenix, and fontawesomefx
    5. Choose the following libraries:
      • com.jfoenix:jfoenix
      • de.jensd:fontawesomefx-fontawesome
    6. Scene Builder will import the latest lib version of each:
      • com.jfoenix:jfoenix:9.0.10
      • de.jensd:fontawesomefx-fontawesome:4.7.0-9.1.2.
    7. All of the imported new components are now selectable in the Custom section of the library manager.

    The progress circle thing isn't in Maven central, you will need to import it via the "Add Library/FXML from File System" option of the "JAR/FXML Manager" dialog (I didn't try that).

    jfoenix github page says it needs to be 9+ to work with Java 9+. I don't think jfoenix is all that well maintained and (from some other questions about the library on StackOverflow), it mostly works in recent SceneBuilder builds, but not well and some of its components don't behave well in SceneBuilder.

    Related:

    Similarly, fontawesomefx has version 9.1.2 which has a manifest with an automatic module in it maven repo entry, which allows it to work. I don't know where up-to-date documentation on that project is, but it appears that there are multiple packages that you can use depending on the font library you want to access, I just picked the one which uses the fontawesome icon library.

    Related:

    scene

    JavaFX 8 to JavaFX 17 conversion approach advice

    I suggest:

    1. Changing your project to a modular project by defining a module-info.java.
    2. Using the most recent stable version of Java and JavaFX (17.0.2)
    3. Using the most recent stable versions of the dependent libraries.
    4. Importing libraries via a build tool:
      • I'd recommend Maven unless you really know Gradle.
    5. Run the app without any VM options for exports and opens etc.
      • Define the module use information in your module-info.
    6. Ensure that your app works fine in those conditions (fixing any issues that arise).
    7. Then try to import the same library versions and your fxml into scene builder.