Importing JFoenix library to SceneBuilder - javaFX

2019-02-07 09:11发布

问题:

I downloaded library JFoenix.jar from official site for Java 8.

I want to import that library to Scene Builder (Gluon). But everytime I try to import it, I dont have all elements from that library (it misses for example JFXButton, JFXTextarea etc.).

I can import only 21 elements from that library, and I dont know what I am doing wrong. Anyone can help?

Screenshots:

Importing library

only imports 21 elements:

回答1:

Many JavaFX custom controls are no longer compatible between Java 8 and 9 versions due mainly to the changes in the JavaFX API (if they were using private skins).

This can be noticed with Scene Builder, which is a JavaFX application after all running either Java 8 or 9.

If you want to add custom libraries like JFoenix to Scene Builder you have to choose the right library for the right version:

  • JFoenix 8.0.2 works fine for Scene Builder 8.4.1
  • JFoenix 9.0.1 works fine for Scene Builder 9.0.1

JavaFX 8

Scene Builder 8.4.1, JAR/FXML Manager -> Manually add Library from Repository, and search for com.jfoenix, jfoenix, selecting the latest 8 version (8.0.2):

then click Add Jar, you'll see 44 components:

JavaFX 9

Scene Builder 9.0.1, JAR/FXML Manager -> Search repositories for jfoenix and select com.jfoenix:jfoenix as this will pick the latest version available:

Then click Add Jar, it will add 44 components again.

Mixing versions

But if using Scene Builder 9.0.1 you select 8.0.2 (manually add Library from Repository, and search for com.jfoenix, jfoenix, selecting the version, 8.0.2), you will get only 23 components:

These components seem compatible between Java 8 and 9, while the 21 missing are no longer compatible.

At the end, it will depend on your real project. If you are targeting JDK 8, I'd suggest you stick to Scene Builder 8.4.1, so you can use the same library versions as in your project.