Link to home
Start Free TrialLog in
Avatar of GilaMonster
GilaMonster

asked on

20 easy points, Re: closing Frames

I have had the most trouble closing my Frames. I know the Frame ignores the Event.WINDOW_DESTROY. So without using System.exit(0), how can I get my Frames to close?
ASKER CERTIFIED SOLUTION
Avatar of jpk041897
jpk041897

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GilaMonster
GilaMonster

ASKER

Thanks for the quick reply.

Your I have tried your suggestions. Here is the code that I thought would do the job; however, when I hit the 'X' in Win 95 to close the frame nothing happens.

Thanks

 public boolean handleEvent(Event event)
  {  
      if (event.id == Event.WINDOW_DESTROY)
      {
            hide();         // hide the Frame
            dispose();      // free the system resources
            System.exit(0); // close the application
            return true;
      }
      return super.handleEvent(event);
   }
What platform and JDK version are you running under?
Since a Frame is derived from Window, which is derived from container which is derived from component, you might want to try:

YourFrame.getParrent().remove(YourFrame);

and see if that works.