Use a callback reference to the Applet that is passed in to the CTOR of the Frame then have the Frame use the callback reference to set a value on the applet via an accessor method you have provided.
There are many ways to implement the coupling. You can make the Frame class a member class of the applet and then it has direct access to the other member variables of the applet or you can create an accessor method to the variable(s) you want the frame to be able to change and then pass a reference to your specific type of applet to the frame on instantiation like above. The frame then uses this callback ref to call the accessor methods and interact with the frame. There are pluses and minuses to each approach. It just depends on how extensible you want things to be. The tighter you couple the relationship between the two classes, the harder it is to change later. Sometimes it is easier to create some interfaces which include specific functionality then implement these interfaces in your two classes. This makes it easier to change things later.
If you need more concrete examples, let me know.
meadandale@yahoo.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.