OK, here goes.
MVC pattern which stands for Model View Controller. This means that there is a complete seperation of code for the GUI, the business logic, and the data. The Model is the data. The view is the GUI and the Controller is the class that controls everything. It will handle the Actions for you, it will have the business logic, and it will pass the model to the view to display.
How do you do this in
Java.
In the GUI you will have Hook methods. like such:
What this does is allow any class that Implements ActionListener to pass a reference of itself to the GUI to be able to Listen to the Actions of the JButton on my GUI for searching.
Now there are two trains of thought and both are fine for the assignment. In my assignment I have the controller implement ActionListener and have one method that hooks all the methods in the Controller to each Action in the GUI.
Example:
In the assingActionListener, I use Anonymous inner classes that will basically have the SearchButton when pressed makes the searchFlight() method, in the Controller, run.
The Controller has a reference to the GUI class.
You can further decouple this by using Action classes that holds a reference to the Controller and the GUI without the GUI or COntroller having any references to each other. This is a nice solution, but you can receive perfect marks, like I did, in this section using my solution, which isn't completely decoupled. Meaning the Controller knows the GUI. But my definition of Controller is one that controls.
Good Luck, and I hope this helps.
Having the ActionListeners in the GUI or as one class that has a big switch statement is a bad design.
Mark