In my application there are many views(sub components) and only one controller. Selecting some options in one view can change the layout and number of components in another view. The controller initialises the view, which in turn creates all the sub components.
In an application such as this does the controller need to have a reference to all the sub components? As in a listener in one view calls the controller to carry out the action and then needs to update the other view. I feel that the controller should not have a reference to all the views but dont know where to go form here. The example in the Head first design patterns book only has one view so I am stuck.
++++++++++++++++++++++++
More detail. The game I am writing is a checkers (draughts) game. In one scenario when the computer is playing against itself the user has to choose some options before the game starts. One such option is to choose the games strategy for certain periods during the game. Such as when it has 12 to 8 pieces on the board it will attack more, 8 to 4 pieces on the board it will be more defensive.
The way the game GUI is structured at the moment, is that there is one overall JPanel (RightContainerFrame) this contains the other JPanels; there is then one JPanel (StartGamePanel) in which the user can configure the game. There is also a JTabbedPane (jTabbedPane1) which contains tabs. Currently in the StartGamePanel when a user selects a certain option in a JComboBox, tabs need to be added or removed from jTabbedPane1.
The way I achieve this currently is in StartGamePanel
RightContainerFrame.getInstance().generateAndDisplayPlayerTwoRangeTabs(numberOfRangeTabsNeeded);
Now I know this is all wrong as I have one view, StartGamePanel directly changing another view JTabbedPane by calling a method in another there container view RightContainerFrame.
I am open to any suggestions as to how to structure this problem.
First I could move the jComboBox1ActionPerformed
method to the controller. This could either update a model for the jTabbedPane1. Or it could call a method directly in the jTabbedPane1 to display the number of tabs required.