'Java Swing - Passing an Event from child to parent without storing parent in child

I'm making a game in Java Swing and I've come across an issue where I need to signal to my UI class MainWindow (that contains an instance of GameLogic) that the player has leveled up and that it needs to display the appropriate UI.

As I mentioned above MainWindow contains an instance of GameLogic and as its name implies it is responsible for updating and maintaining the game. When the player levels up I want to invoke an Event which the MainWindow can handle. How can I make this happen?

I want to avoid storing the MainWindow instance's reference in GameLogic as that could lead to problems when I'm deserializing a save using Gson. I tried simply having GameLogic extend ActionEvent, but I don't think that's a correct path to take as I'd need to call ActionEvent's constructor within GameLogic as super but ActionEvent requires a non-null source which can't be GameLogic as it is being constructed so this isn't yet usable, but no other Object instance would make sense to be used there.

Another approach I thought of was just having an instance of ActionEvent within GameLogic but how would I set its actionListener to MainWindow without storing a reference for it?

At this point I realized that this was probably already done a lot, so it's better to resort to tried and tested solutions, so here I am. I'd appreciate general advice or links to sites where this specific issue is explored and solved/explained.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source