Calling a method on original class from created class
I hope I worded the title correctly :)
I am making a small java.net wrapper where the main class creates an instance of the wrapper (JSock) and somewhere along the lines, when JSock gets a connection request it can call a method on the main class called connectionRequest()
So far i have this working fine but I have to always make sure the main class is called the same name (Logic) because the way I get the instance of the main class to call logic.connectionRequest(), I have to pass "this" into the constructor. i.e
JSock listenSock = new JSock(port, this)
then in the JSock I have "Logic parent" which contains the reference to the "parent" class.
Simplified code is...
JSock listenSock = new JSock(port, this);
public void connectionRequest()
public JSock(Logic newParent)
parent = newParent;
Is there a way to do this without needing to pass the instance of Logic when creating the class?
Super is only for derived classes isnt it?
Any help would be greatly appreciated!