What is the purpose of URL & ResourceBundle in the following code
public class HelloWorld implements Initializable {
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
...
}
}
What is the purpose of URL & ResourceBundle in the following code
public class HelloWorld implements Initializable {
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
...
}
}
As per the documentation for the Initializable interface:
NOTE This interface has been superseded by automatic injection of location and resources properties into the controller. FXMLLoader will now automatically call any suitably annotated no-arg initialize() method defined by the controller. It is recommended that the injection approach be used whenever possible.
You should use something like this instead:
public class Controller
{
@FXML
private URL location;
@FXML
private ResourceBundle resources;
public void initialize()
{
// do your setup stuff here
// fxml loader will call this for you
}
}
Additional note: The above quote calls for a 'suitably annotated no-arg initialize() method'. If for whatever reason you require a private initialization, make sure you 'suitably annotate' it with the @FXML annotation.