I have a fxml file build from fxml builder and I am using it by a loader in Java.
URL resource = getClass().getClassLoader().getResource("fxmlFile.fxml"); FXMLLoader loader = new FXMLLoader(resource, resourceBundle); Pane rootPane = (Pane) loader.load(); this fxml file maps click event to my class;
<Group id="Group" layoutX="0.0" layoutY="0.0" onMouseReleased="#handleThis" scaleX="1.0" scaleY="1.0"> ... <Group/> so I implement my handler in my class, lets call it MyClass;
public class MyClass { public void createScene() throws IOException { URL resource = getClass().getClassLoader().getResource("fxmlFile.fxml"); FXMLLoader loader = new FXMLLoader(resource, resourceBundle); Pane rootPane = (Pane) loader.load(); ... } @FXML public void handleThis(ActionEvent event) { System.out.println("from MyClass"); } ... } Now I extend MyClass as MyExtendedClass and override handleThis method;
public class MyExtendedClass extends MyClass { @Override public void handleThis(ActionEvent event) { System.out.println("from MyExtendedClass"); } } My question is, I cannot manage to work handle method in my extended class. It does not overrides it. How can I achieve to make it print "from MyExtendedClass" instead of "from MyClass"?
FXMLLoadereven know about the subclass?