posted 15 years ago
It's probably been asked before, but I didn't find any other threads that fits my question good enough:
- I have a class GUI and a class Control.
- GUI is instanciated through Control, I will not make any new instances of Control or GUI.
- When a button is clicked in GUI, I want it to fire a method in Control.
I can think of 2 possible alternatives for doing this
A) In same way manage to have the actionPerformed-method in GUI to fire methods in Control. I tried searching for this, but I don't really know exactly what to search for, I've only found examples where everything happens in one class.
B) Make actionPerformed change a variable somewhere in GUI, and then use a timer or similar in Control to check regularly if the variable in GUI has changed. Haven't tried making any timers yet, but I suppose it should work, although it might not be the most effective way.
So, is it even possible to make actionPerformed fire a method in another class without instanciating it?
If not, is there any better way than using a timer to check a variable for changes?