Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2005

Tip: Looking for answers? Try searching our database.

Preforming functions on JFrame Close...

Thread view: 
balgach@gmail.com - 07 May 2005 02:06 GMT
Hello all,

ive got a JFrame and right now i have it set to

frmMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

however i would like to run a function (cleanUp()) just before the
window closes, but only when its been notified that its been closed.
How would i go about doing that? Thanks!

Cheers,
Adam.
Betty - 07 May 2005 02:16 GMT
> Hello all,
>
[quoted text clipped - 8 lines]
> Cheers,
> Adam.

       // trap window close and do something in an anonymous inner class
       frame.addWindowListener(new WindowAdapter()
               {
                   public void windowClosing(WindowEvent e)
                   {
                       // your stuf here
                       System.exit(0);
                   }
               });
balgach@gmail.com - 07 May 2005 02:35 GMT
ah i knew it was something simple, thanks!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.