File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Jframe and JApplet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Jframe and JApplet" Watch "Jframe and JApplet" New topic
Author

Jframe and JApplet

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
ok, say I have a chatclient running in a jframe to display it. And then I put that same client in a web page as an applet.

when i close the page the applet is on, is that equivilant to pressing the close 'X' on the jframe?

Thanks A Lot,


Justin Fox


You down with OOP? Yeah you know me!
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
and if so, if i close the JFrame/JApplet will that close the socket that is open in that chatclient?

or do i need to put a windowlistener in to check to see if its open?
or something along those lines.


Thanks,

Justin Fox
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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).


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jframe and JApplet
 
Similar Threads
closing JFrame on button click
Redirect from an Applet to a different HTML page
destroy() method not called
JFrame ?!!!
detect Applet user inactivity