I would like to call an abstract method in each subclass. Here is an example:
public abstract class ControllerAbs implements UiListener
/**
* implements from ui listener. when it's called, then must the ui be updated
*/
@Override
public synchronized void Update() {
// for change ui elements from another no fx-thread
// see http://stackoverflow.com/questions/21674152/timer-error-java-lang-illegalstateexception
Platform.runLater(new Runnable() {
@Override
public void run() {
UiUpdate();
}
});
}
/**
* update ui in subcontroller
*/
protected abstract void UiUpdate();
}
Now, I extend my subclass with the abstract method:
@Override
protected void UiUpdate() {
// update ui
}
But when I have more than one subclass that will extend from controllerabs, only the first subclass will be updated. What is wrong?
I want a method that will be called in each subclass.
Best regards, sandro
Use the keyword
super
in order to call the method for the supclass defined. E.g. something like the following:Using this keyword, you can refer to the object that is higher in the hierarchy and call its implementation of the method.