This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
When you push the 'X' of a JFrame, this generates a WindowEvent, which is sent to any WindowListeners you have attached to the JFrame (and the windowClosing/windowClosed method of the listener is called).
Applets/JApplets have lifecycle events in the Applet class to handle things like navigating away from the page, the applet being destroyed, etc. applet.destroy() is probably analogous to pressing the 'X' to close an application - however, it's probably better to create a socket in start() and release/destroy it in stop() - this means that the applet won't hang onto the socket while it's not 'active' (i.e. the use has navigated away from the page the applet is on).
Write once, run anywhere, because there's nowhere to hide! - /. A.C.