Solved

20 easy points, Re: closing Frames

Posted on 1997-05-29
4
205 Views
Last Modified: 2010-04-16
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?
0
Comment
Question by:GilaMonster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 20 total points
ID: 1221087
Call the frames dispose() method.

dispose() destroys the frame. If thats not what you want, then you can call its diasable(true)  and setVisible(false) methods.
0
 

Author Comment

by:GilaMonster
ID: 1221088
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);
   }
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1221089
What platform and JDK version are you running under?
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1221090
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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question