So I'm familiar with the Model-View-Controller (MVC) pattern, but still having difficulty when writing a Swing GUI app and having certain actions (button clicks, etc.) effect higher level classes in the application. I've used MVC, Observer pattern, etc. for certain situations but what I find difficult to deal with is this type of situation:
I have a JFrame (a class that extends JFrame). It has a menu bar (another class that extends JMenuBar) as a member variable. It also has a panel (a class that extends JPanel) as a member variable, and this panel contains a button as a member variable. The JMenuBar has a "File" drop down menu (another class that extends JMenu) as a member variable. The "File" drop down menu has a menu item, say "Create new file" as a member variable.
Obviously, there is some nesting here. What I want to happen (elegantly) is when the button in the panel is clicked, the "Create new file" menu item should be disabled. The point is that not all the swing components I've described are not accessible in one class... they are scattered in other classes as private member variables. The button is a few levels below where the file items are, etc. So do I use a model? If so, how? Do I use some type of Singleton state classthat somehow manages everything?