Closing frame??? Please Help!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Closing frame??? Please Help!

  1. #1
    Join Date
    Nov 2002
    Posts
    5

    Closing frame??? Please Help!

    How can I make frame closing by clicking with mouse on button 'x' in upper right corner of window?

  2. #2
    Join Date
    Sep 2002
    Posts
    124
    Hi, Asim

    Paste the following code into your class after the public instance of it:

    {
    addWindowListener(new WindowAdapter()
    {
    public void windowClosing(WindowEvent e)
    { System.exit(0);}
    });


    Please consult attachment for a better idea.

    Regards
    Joyous Monkey
    Attached Files Attached Files

  3. #3
    Join Date
    Dec 2002
    Posts
    17
    You can also use:
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    for example, for class Test:
    // this would be in main()
    Test testFrame = new Test();
    testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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