I know that there are listeners in JavaFX, and i’m sure Java. But I’m confused as how to implement them.
I have a boolean variable that is changed throughout my program. Everytime the boolean is changed, I want a function myFunc() to be ran.
Can this be done easily?
Advertisement
Answer
As simple as this:
public void changeBooleanFlag(boolean bEnabled) { if(booleanFlag == bEnabled) return; booleanFlag = bEnabled; myFunc(); }
and whenever you want to change the boolean flag, you should do it via this method.