I am programming a client server program over sockets.
I have a main class where I Open a JFrame class and inside the JFrame I have another class with a panel. This panel has 2 buttons. When I click this buttons I need to send a command to the server.
As my Buttons are in the panel class, my actionlisteners for this buttons are too. My socket is initiated in the main class and is in a while(true) loop.
How can I get to the socket from my actionlisteners, as my socket instance is unknown in Jpanel class. How can I fix this? I can't pass my socket object to the frame, I tried and that doesnt work.