> Hi
>
[quoted text clipped - 22 lines]
> }
> }
How about something like a listener? The network code defines an
interface with a method for each type of event it can report, with
suitable parameters to convey the details. The GUI code creates an
object that implements that interface and passes it to the network code
constructor.
In the case of a GUI, some methods in the listener object may need to
call invokeLater to get things run in the event handling thread. That is
an issue for the GUI, and not something the network code should need to
care about.
Patricia
Pkid - 13 Feb 2007 18:44 GMT
> > Hi
>
[quoted text clipped - 35 lines]
>
> Patricia
Hi
Sorry to bug you again but if I change it to the following it seems to
use less memory. Not creating the new thread? Thanks!
public class ServerGUIListener implements NetworkListenerInterface,
Runnable
{
String eventDescription;
ChatServerGUI sourceObject;
public ServerGUIListener(ChatServerGUI new_sourceObject)
{
sourceObject = new_sourceObject;
}
public void TalkBack()
{
sourceObject.RaiseEvent(eventDescription);
}
public void run()
{
TalkBack();
}
public void EventHappened(String new_description)
{
eventDescription = new_description;
javax.swing.SwingUtilities.invokeLater(this);
}
}