I'm writing simple Peer-Server-Peer chat application in Swing. On the client side, there is a 'Client' object responsible for Client-Server communication and 'MainWindow' which is a main jForm.
Upon receiving a message, 'Client' needs to notify the 'MainWindow' about the new message. However, 'MainWindow' is an object created at the start of the program (in my case after the 'Client' is created), so I'm looking for a way of passing 'MainWindow' reference to 'Client'.
I was thinking about creating 'Resource' class with static references to objects I need to communicate with within my app, but it doesn't seem very elegant.
Is there a better way to do this?