Component to help make a bridge through .fxml files and Java. This component loads FXML files and initialize it through Controllers.
To help deal with Controller Initializations it was created IInitializable<A>. This interface has 1 method init(A arg), and Controllers that need arguments to initialization should implement this interface and pass the argument of init(arg) on constructor of FXMLFile.
During the mounting precess FXMLLoader can throw Exception, if that happens a ComponentException will be thrown.
public FXMLFile(String fXMLFilePath, A initializableArgument)
init(argument) method for controllers that implement IInitializable.
There are more constructors with different parameters, but all will internally call this first one.
Variations :
initializableArgument this value is assumed as null.public FXMLFile(String fXMLFilePath)
// Without initialization of Controllers
try {
FXMLFile<AnchorPane, Void> fxmlFile = new FXMLFile<>("path");
fxmlFile.mount();
AnchorPane pane = fxmlFile.getNode();
} catch (ComponentException e) {
//Treat Exception
}
// For Controllers that implements IInitializable<A>
try {
FXMLFile<AnchorPane, A> fxmlFile = new FXMLFile<>("path", argument);
fxmlFile.mount();
AnchorPane pane = fxmlFile.getNode();
} catch (ComponentException e) {
//Treat Exception
}