A DESCRIPTION OF THE PROBLEM :
When implementing Initializable in the JavaFX controller, the abstract method initialize should be @Override public void initialize(URL url, ResourceBundle rb){...} and not @Override public void initialize(URL url, Resource r){...}.
The full incorrect code in docs
package com.foo;
public class MyController implements Initializable {
public Button button;
@Override
public void initialize(URL location, Resources resources)
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked me!");
}
});
}
}
What it should be.
package com.foo;
public class MyController implements Initializable {
public Button button;
@Override
public void initialize(URL location, ResourceBundle resources)
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked me!");
}
});
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
View the docs at https://openjfx.io/javadoc/22/javafx.fxml/javafx/fxml/doc-files/introduction_to_fxml.html.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected to see the following.
package com.foo;
public class MyController implements Initializable {
public Button button;
@Override
public void initialize(URL location, ResourceBundle resources)
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked me!");
}
});
}
}
ACTUAL -
I currently see the following.
package com.foo;
public class MyController implements Initializable {
public Button button;
@Override
public void initialize(URL location, Resources resources)
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked me!");
}
});
}
}
When implementing Initializable in the JavaFX controller, the abstract method initialize should be @Override public void initialize(URL url, ResourceBundle rb){...} and not @Override public void initialize(URL url, Resource r){...}.
The full incorrect code in docs
package com.foo;
public class MyController implements Initializable {
public Button button;
@Override
public void initialize(URL location, Resources resources)
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked me!");
}
});
}
}
What it should be.
package com.foo;
public class MyController implements Initializable {
public Button button;
@Override
public void initialize(URL location, ResourceBundle resources)
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked me!");
}
});
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
View the docs at https://openjfx.io/javadoc/22/javafx.fxml/javafx/fxml/doc-files/introduction_to_fxml.html.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected to see the following.
package com.foo;
public class MyController implements Initializable {
public Button button;
@Override
public void initialize(URL location, ResourceBundle resources)
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked me!");
}
});
}
}
ACTUAL -
I currently see the following.
package com.foo;
public class MyController implements Initializable {
public Button button;
@Override
public void initialize(URL location, Resources resources)
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked me!");
}
});
}
}