Basically I have a method in my Gui class that prints and appends text and I need to use that method in other classes like my Player class. How do I use that method? If I were to make another Gui object in the player class it would create another JPanel which would be bad right? If I need to move that method to another class be my guest to suggest that. Thanks guys!
Share
If the
Playerclass needs to call methods on theGUIclass, why not have thePlayerclass take theGUIinstance as a constructor argument? So whatever code creates thePlayerwill have to tell it whatGUIit should use for such method calls.This is an approach known as dependency injection, and is generally considered to be superior to singletons or static methods.