Can a JFrame dispose itself?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Can a JFrame dispose itself?

  1. #1
    Join Date
    Dec 2002
    Posts
    2

    Can a JFrame dispose itself?

    Hi, I am writing an app and I would like for a JPanel to destroy the JFrame that it's embedded in. At the moment, I am doing a dispose on the frame. Is there any way that a JPanel can call dispose() on the frame it is embedded in?

    I have tried the following, but it does nothing...
    ((Window) getTopLevelAncestor()).dispose();

    This compiles but doesn't close the window.

    Thanks in advance,
    Dave.

  2. #2
    Join Date
    Dec 2002
    Posts
    2
    I apologise..... it was my mistake. This method works fine, I hadn't added the right button listeners..... DOH!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center