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?

Était-ce utile?

La 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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top