W
wEEdpEckEr
Hi,
I was wondering if it is possible to pass on a function as parameter.
Because I have a class that extends a thread and uses a socket, and
listens constantly to this socket. Now when something passes over the
connection, the output needs to be displayed in a JTextArea. So what I
would like to do is:
public void displayOutput(String msg)
{
outputBox.append(msg);
}
and when initializing the thread:
server = new Server(this.displayOutput());
only I have no idea what I would have to in the constructor of the
Serverclass nor how to call the function from within the server class. I
know it's possible in C++, but about Java I'm not sure.
Thanx if anyone knows the answer to this.
greetings
Tim
I was wondering if it is possible to pass on a function as parameter.
Because I have a class that extends a thread and uses a socket, and
listens constantly to this socket. Now when something passes over the
connection, the output needs to be displayed in a JTextArea. So what I
would like to do is:
public void displayOutput(String msg)
{
outputBox.append(msg);
}
and when initializing the thread:
server = new Server(this.displayOutput());
only I have no idea what I would have to in the constructor of the
Serverclass nor how to call the function from within the server class. I
know it's possible in C++, but about Java I'm not sure.
Thanx if anyone knows the answer to this.
greetings
Tim