DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Lim Wing Hoe Guest

    System.exit(0) not working :(

    I have System.exit(0) inside windowClosing(WindowEvent e) method, but when I
    close the window, it isn't working. What could be wrong?

    --



    Best Regards,
    Wing Hoe
    ---------------------------------------------------------------
    ICQ: 2213281
    Email: winghoe@hotmail.com
    www: http://pwp.maxis.net.my/winghoe
    ---------------------------------------------------------------





  2. #2
    alberto Guest

    Re: System.exit(0) not working :(


    if the code is correctly syntaxed do you have....
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    imoprt java.awt.event.WindowListener;
    --alberto

    "Lim Wing Hoe" <winghoe@hotmail.com> wrote:
    >I have System.exit(0) inside windowClosing(WindowEvent e) method, but when

    I
    >close the window, it isn't working. What could be wrong?
    >
    >--
    >
    >
    >
    >Best Regards,
    >Wing Hoe
    >---------------------------------------------------------------
    >ICQ: 2213281
    >Email: winghoe@hotmail.com
    >www: http://pwp.maxis.net.my/winghoe
    >---------------------------------------------------------------
    >
    >
    >
    >



  3. #3
    Dan Guest

    Re: System.exit(0) not working :(


    class MyFrame extends JFrame{
    MyFrame(){
    *
    *
    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent evt){
    System.exit(0);
    }
    });
    }

    }



    "Lim Wing Hoe" <winghoe@hotmail.com> wrote:
    >I have System.exit(0) inside windowClosing(WindowEvent e) method, but when

    I
    >close the window, it isn't working. What could be wrong?
    >
    >--
    >
    >
    >
    >Best Regards,
    >Wing Hoe
    >---------------------------------------------------------------
    >ICQ: 2213281
    >Email: winghoe@hotmail.com
    >www: http://pwp.maxis.net.my/winghoe
    >---------------------------------------------------------------
    >
    >
    >
    >



  4. #4
    Lim Wing Hoe Guest

    Re: System.exit(0) not working :(

    Yes, I have the imports correct also

    import java.awt.events.*;

    public class myClass extends JFrame implements WindowListener
    {.....
    public void windowClosing(WindowEvent e)
    { System.exit(0);
    }
    .....
    }

    In my other classes, that extends JInternalFrame, the
    windowClosing(WindowEvent e) method is as it it's not working as well. I
    have changed it to JInternalFrameListener,

    public void internalFrameClosing(InternalFrameEvent e)

    but nothing gets executed.

    --



    Best Regards,
    Wing Hoe
    ---------------------------------------------------------------
    ICQ: 2213281
    Email: winghoe@hotmail.com
    www: http://pwp.maxis.net.my/winghoe
    ---------------------------------------------------------------


    "alberto" <albert77@rocketmail.com> wrote in message
    news:39f71821$1@news.devx.com...
    >
    > if the code is correctly syntaxed do you have....
    > import java.awt.event.ActionEvent;
    > import java.awt.event.ActionListener;
    > import java.awt.event.WindowEvent;
    > imoprt java.awt.event.WindowListener;
    > --alberto
    >
    > "Lim Wing Hoe" <winghoe@hotmail.com> wrote:
    > >I have System.exit(0) inside windowClosing(WindowEvent e) method, but

    when
    > I
    > >close the window, it isn't working. What could be wrong?
    > >
    > >--
    > >
    > >
    > >
    > >Best Regards,
    > >Wing Hoe
    > >---------------------------------------------------------------
    > >ICQ: 2213281
    > >Email: winghoe@hotmail.com
    > >www: http://pwp.maxis.net.my/winghoe
    > >---------------------------------------------------------------
    > >
    > >
    > >
    > >

    >




  5. #5
    Lim Wing Hoe Guest

    Re: System.exit(0) not working :(

    I found the solution.
    OK here goes, Kean from comp.lang.java.* newsgroup replied to my post.

    He mentioned to me to add _addWindowListener(this) to my constructor and it
    works.

    codes required:

    import java.awt.event.*;

    class myJFrame extends JFrame implements WindowListener
    {
    public myJFrame()
    {
    addWindowListener(this);
    }

    //write all the methods for windowClosing, windowClosed, etc. here.
    public void windowClosing(WindowEvent e)
    {
    System.exit(0);
    }
    }

    This work. I ran my codes a few times, including adding a System.out.println
    statement to make sure that the method windowClosing() is executed and it
    works.



    --



    Best Regards,
    Wing Hoe
    ---------------------------------------------------------------
    ICQ: 2213281
    Email: winghoe@hotmail.com
    www: http://pwp.maxis.net.my/winghoe
    ---------------------------------------------------------------



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links