I have asked so many questions about Scene Builder that I am starting to feel like I might be a mild annoyance to some people. But now another problem has revealed itself. I previously posted this question in regards to importing nested custom nodes into Scene Builder. My knight in shining armor came through and helped me solve that issue. Now I have a new problem though. The symptoms are exactly the same but the cause seems to be different. Again I have no idea how to bug test this issue (I would be very happy if someone were to teach me how. I do not fully understand the bug testing methods of the last answer unfortunately.) but it seems to have come from nowhere.
So the issue is, just as before, that when I try to import a jar file containing a custom node with other nested nodes inside the outermost container doesn't get imported into Scene Builder. Last time around this was solved by adding
fxmlLoader.setClassLoader(getClass().getClassLoader());
to my java controller code before loading the fxml but this doesn't fix it this time. Here is all the source code. To be honest with you the issue is probably something quite dumb that I have overlooked and if this is the case I am sorry in advance.
Thanks for all help!
EDIT: I should ad that all jars run fine by themselves. They simply do not play nicely with Scene Builder.
EDIT 2: As pointed out in the comments I should try to make the problem a little more accessible, sorry about that. So here is the structure. The outermost component is what I call a NumberSlider. This contains the two other custom components the NumberField and the InfoIcon (see image below). The inner components are imported fine and the outer is not. The structure of the NumberSlider is basically a slider which has its valueProperty bound to the valueProperty of the NumberField. The NumberField is essencially a TextField that allows the user to input text to change its valueProperty and if the valueProperty changes the text changes to match this. I believe the problem lies in the making of the slider variable since this is the component that doesn't import as it should. This is the constructor.
//Properties
private final BooleanProperty logarithmic;
private final BooleanProperty ticks;
//Variables
@SuppressWarnings("unused")
private boolean lock = false;
//Structural Elements
@FXML private Label label;
@FXML private Slider slider;
@FXML public NumberField field;
@FXML private InfoIcon info;
public NumberSlider(@NamedArg("logarithmic") boolean logarithmic, @NamedArg("ticks") boolean ticks,
@NamedArg("intSlider") boolean intSlider, @NamedArg("value") double value,
@NamedArg("min") double min, @NamedArg("max") double max) {
this.logarithmic = new SimpleBooleanProperty(this, "logarithmic", logarithmic);
this.ticks = new SimpleBooleanProperty(this, "ticks", ticks);
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("NumberSlider.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
fxmlLoader.setClassLoader(getClass().getClassLoader());
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
field.reconfigureLogic(value, min, max, intSlider);
//An awfully long code block that basically binds the two properties with change listeners in different ways depending on the input arguments.
}
The rest of the NumberSlider is only getters and setters for its various properties. I do not believe there is a problem with the changelisteners since they all work fine when running from my IDE.
EDIT 3: See the answer below for a great explanation. I just want to add that in my source code the NumberSlider needs getters and setters for all its properties, even those inherited from NumberField. Otherwise it won't play nicely with Scene Builder.