• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jframe and JApplet

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic