Solved

20 easy points, Re: closing Frames

Posted on 1997-05-29
4
176 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
where is session ID cache stored 1 46
Java passing arguments (type error) 2 48
egit plugin on eclipse 8 28
table example 4 20
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

930 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now