I created "initialize" method automatically, out of "implements Initializable" class. After that, I added simple code to load Menu Screen designed in Scene Builder. Part of this code requires handling an exception (IOException). However, when I try to simply add "throws IOException" to the method itself, it gives me an error that reads:
'initialize(URL, ResourceBundle)' in 'com.javafx.controllers.RootController' clashes with 'initialize(URL, ResourceBundle)' in 'javafx.fxml.Initializable'; overridden method does not throw 'java.io.IOException'
I tried it with other "initialize" method made by myself and this error doesn't occur anymore. I would be glad if someone could explain this...
public class RootController implements Initializable {
@Override
public void initialize(URL url, ResourceBundle resourceBundle) throws IOException {
loadMenuScreen();
}
public void initialize() throws IOException {
loadMenuScreen();
}
public void loadMenuScreen() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/javafx/screens/MenuScreen.fxml"));
Pane pane = loader.load();
MenuController menuController = loader.getController();
menuController.setRootController(this);
setScreen(pane);
}
The error occurs at the first initialize but not at the second. I understand that it has probably something to do with (URL url, RescourceBundle resourceBundle) but I don't understand how...