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
---------------------------------------------------------------
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
>---------------------------------------------------------------
>
>
>
>
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
>---------------------------------------------------------------
>
>
>
>
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
> >---------------------------------------------------------------
> >
> >
> >
> >
>
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
---------------------------------------------------------------