Question

I created a game in a separate panel class from the GUI main class. I am trying to find a way to update the score and level text fields found inside the GUI main class, when a method inside the panel class is executed. I tried to use the observer design pattern but the panel class already extends JPanel and can only extend one item. Is there an alternative to this?

Was it helpful?

Solution

Implementation of observer pattern does not require that you extends your new JPanel class. You should to define the interface(s) and implement that/those interface(s) in your class.

I recommend to you take a look on this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top