You can do the following;
Define listener interface:
public interface MyListener(){
public void doNotify(String message);
}
The Socket class (has a methot to add listeners that are notified on onRecieve()):
public class SocketClass {
private List<MyListener> listeners = new ArrayList<MyListener>();
public void addListener(MyListener listener) {
listeners.add(listener);
}
public void onRecieve(){
/* your code*/
for (MyListener l : listeners)
l.doNotify("Socket has recieved something ;P");
}
}
The Gui class has a method that passes on the listener:
public class GuiClass() {
SocketClass s = new SocketClass();
public void addListener(MyListener listener) {
s.addListener(listener);
}
}
And finally the main class (implements the listener interface and adds itselef to GuiClass as listener):
public class MainClass implements MyListener {
public static void main(String[] args)
{
GuiClass g = new GuiClass();
g.addListener(this);
}
public void doNotify(String message) {
System.out.println(message);
setPostition();
}
private void setPosition()
/* your code here */
}
}
A good example is also THIS.
Good luck and Regards