So here's the rundown. I have a base class, I want to put a clickHandler in it because all of my subclasses will need it, but they will all execute different code when it is triggered. My question is, how can i have a clickHandler in my base class and when it is triggered, it can execute specific code from the subclass?
my code is long and complicating, so ill give an example.
Base Class
public class CountProgram extends Canvas {
public CountProgram(){
super();
init();
}
private void init() {
currGrid.addCellClickHandler(new CellClickHandler() {
public void onCellClick(CellClickEvent event) {
//here is where i want to call subclass code to execute
}
});
}
}
subclass:
public class stHrTeacherCount extends CountProgram {
public stHrTeacherCount(StaffMain sm,String permission){
super();
_sm=sm;
setPermission(permission);
}
public void executeCode() {
//here would be the code i want to execute when the event is triggered
}
}
Ive tried some things, like setting variables from "executeCode()" to variables in the super class, but it was messy and i was unable to get it to work successfully. Would be nice if I could just pass a method as a parameter, but unfortunately you can in Java and I dont know an alternative. hope i explained well enough, Thanks!