I am following this in creating a custom component and importing it. However, when it gets to the Import Dialog after clicking the jar file, it does not appear. When I comment out the code the tutorial used for the constructor, it appears again. However, none of the subcomponents I used to make the custom one appear. Why and how do I fix it?
Also, I am using a VBox instead of an AnchorPane (as seen in the tutorial) for my own thing.
Code of constructor as seen in tutorial:
public CommodityImageLabel() {
FXMLLoader fxmlLoader = new FXMLLoader(
getClass().getResource("/fxml/CommodityImageLabel.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
Code for my own example's constructor:
public While() {
FXMLLoader fxmlLoader = new FXMLLoader(
getClass().getResource("BlocksFXML/While.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
Edit1: I tried commenting out parts of the code, and when I comment out the try-catch part, it makes the component appear in the dialog, but it still doesn't show the subcomponents.
Edit 2: The custom component is basically a VBox containing an Hbox with a Label and a TextField. Here is what it's supposed to look like vs what ends up looking like when it successfully imports without the try-catch part.