I have a GUI with a CheckboxMenuItem and a JToggleButton that perform the same action. I would like to somehow link them together so that they respond to each other as well. If I check the checkbox, I want the JToggleButton to be enabled. If I unclick the JToggleButton, I'd like the checkbox to automatically be unchecked as well.
Is there a way to accomplish this without passing references to the CheckboxMenuItem and the JToggleButton to each other? It seems as though I should be able to do that in the actionPerformed() method, right? Right now I am attempting to implement the Observer design
pattern, but I haven't been able to figure it out yet. Am I missing some obvious way of doing this? Surely this is something that many people have wanted to do before.
Thanks for your help!