posted 19 years ago
I have spent sometime reading about implementing the Model View Controller and have attempted to hook my classes up in a similar fashion.
The TranslationTool is designed as the parent class and as such needs access to all the classes. I have therefore given it instance variables to all the classes and set them within the constructor of the TranslationTool using
The Translator class which listens for the events and does most of the work is passed an instance of the TranslationTool as a parameter of its constructor. This is then copied into a variable inside the constructor.
I think that this class will be able to access all other classes if it uses �parent�
The ControlPanel class public is passed an instance of the Translator class as a parameter of its constructor. This is then copied into a variable inside the constructor.
Can anyone please explain the difference of using � this.� And just simple copying it into a local variable within the constructor???
The TranslationPanel and InformationPanel do not have any link except via the TranslationTool, since it has an instance variable to each class.
I have some get methods which are designed to get at each panel and the use the result to get at the text within the panel.
My main problem is that everything looks beautiful but nothing is functioning. I have setup tests to catch when buttons are pressed and are supposed to print out if a button is hit but nothing is happening.
I would be very grateful for any advice particularly on how to check if events are happening or if there are glaring mistakes in my logic.
I will paste the full code below.
Best wishes
Dianne
TranslationTool sets up the GUI frame
Translator class handles the events from the buttons and then "does task". This class does most of the real work
3 Panel classes:-
TranslationPanel
InformationPanel
ControlPanel
QuitableJFrame is a file I have been supplied with and handles the closing of the GUI