• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jframe and JApplet

 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic