0

When Importing Custom JavaFX Components into SceneBuilder, none of my UI compoments are displayed in the import dialog.

My Custom Component:

package co.za.hein;

import javafx.scene.control.Button;

public class TestButton extends Button {

    public TestButton() {
        super();
    }

}

The import Dialog in Scenebuilder: enter image description here

I compile my Component with java 19.0.2 2023-01-17 and I am using the latest SceneBuilder 19 version. I've tried including javafx dependencies in the jar, but no difference. There is also no stack trace when looking at the Jar analysis report, except when including all javafx dependencies. (All the errors are about jacafx not my component)

Extra Info:

Using VSCode, and compiling using built in export jar function.

I am aware that there are many questions already on stackoverflow around importing Custom components into SceneBuilder, although it seems that none of them had a concise answer. I have provided the most simple example that just should work. There is no documentation I can find on creating Custom Components, only on importing them.

Hein Gertenbach
  • 318
  • 2
  • 13
  • I am already frustrated with the very poor quality of the CSS reference guide, and now this :( not good – Hein Gertenbach Mar 17 '23 at 07:24
  • I guess you saw [the answer on importing a jar](https://stackoverflow.com/questions/29444698/how-to-create-an-fxml-file-for-an-already-created-new-component-in-java-than-add/29444845#29444845). Your sample custom control code looks ok to me. It should be the only file in your imported jar, just one class file and nothing else (run `jar tvf` on the jar to check). Make sure the byte code version compiled to <= byte code version of your SceneBuilder Java runtime. Run SceneBuilder from the command line and check the console output. – jewelsea Mar 17 '23 at 08:26
  • Besides the manifest, it is the only file. I tried running SceneBuilder from console, and it didn't work with ```JAVAHOME (19.0.2)``` but it did work with it's own runtime JAVA (19). ```Error: Could not find or load main class... NoClassDefFoundError``` And there were no errors when importing. – Hein Gertenbach Mar 17 '23 at 09:09

1 Answers1

0

Ass @jewelsea suggested,

Make sure the byte code version compiled to <= byte code version of your SceneBuilder Java runtime

19.0.2 is too new for Scenebuilder using 19.0.0. I though as long as the major version is not bigger than SceneBuilder's it will work, I was wrong.

Hein Gertenbach
  • 318
  • 2
  • 13