Problem With JOptionPane.showConfirmDialog

hello there i've made a KeyEvent When The user Presses The alt+f4 key

(f4 While holding down the alt key) a JOptionPane ConfiramtionDialog appears as follows:

if (k.isAltDown() && k.getKeyCode() == KeyEvent.VK_F4)

{

Toolkit tool3 = Toolkit.getDefaultToolkit();

tool3.beep();

int returnValue2=JOptionPane.showConfirmDialog(null,"Do You Really Want To Exit?","EXIT",JOptionPane.YES_NO_OPTION);

if (returnValue2 == JOptionPane.YES_OPTION)

{

System.exit(0);

}

}

and i want to make that if the user presses the no option or the close

option no thing happen or the focus(control )return to the frame

besause i have a nother windowclosing event and when i press the no or close option it goes to execute the windowclosing event and i want to prevent that? this is the windowclosing event

class MyInner3extends WindowAdapter

{

publicvoid windowClosing(WindowEvent ee)

{

Toolkit tool = Toolkit.getDefaultToolkit();

tool.beep();

JOptionPane.showMessageDialog(null,"The Program Will Now Exit",JOptionPane.ERROR_MESSAGE,image );

System.exit(0);

}

}

could any one help me...thank you

[1758 byte] By [First_knighta] at [2007-11-27 7:49:28]
# 1
I don't understand your problem. What does happen? What should happen instead?
prometheuzza at 2007-7-12 19:30:26 > top of Java-index,Java Essentials,New To Java...
# 2
i want when the user presses the no option i call back the interface(frame) or no action happenbecause it goes to execute the windowclosing event and shows a message dialogthank you
First_knighta at 2007-7-12 19:30:26 > top of Java-index,Java Essentials,New To Java...
# 3
> i want when the user presses the no option i call back the interface(frame) or no action happenhave you included thisframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Michael_Dunna at 2007-7-12 19:30:26 > top of Java-index,Java Essentials,New To Java...
# 4

thanks mr Michael_Dunn it worked

but i have a little bug here that when the user presses the no option

the confirmation message appear again to ask him and when i press

no again the focus return to frame

i want the confirmation message not to appear again when the user

presses the no option.

First_knighta at 2007-7-12 19:30:26 > top of Java-index,Java Essentials,New To Java...
# 5

combine the two

//if (k.isAltDown() && k.getKeyCode() == KeyEvent.VK_F4)

//{

//Toolkit tool3 = Toolkit.getDefaultToolkit();

//tool3.beep();

//int returnValue2=JOptionPane.showConfirmDialog(null,"Do You Really Want To Exit?","EXIT",JOptionPane.YES_NO_OPTION);

//if (returnValue2 == JOptionPane.YES_OPTION)

//{

//System.exit(0);

//}

//}

class MyInner3 extends WindowAdapter

{

public void windowClosing(WindowEvent ee)

{

Toolkit tool = Toolkit.getDefaultToolkit();

tool.beep();

int returnValue2=JOptionPane.showConfirmDialog(null,"Do You Really Want To Exit?","EXIT",JOptionPane.YES_NO_OPTION);

if (returnValue2 == JOptionPane.YES_OPTION)

{

JOptionPane.showMessageDialog(null, "The Program Will Now Exit",JOptionPane.ERROR_MESSAGE,image );

System.exit(0);

}

}

}

Michael_Dunna at 2007-7-12 19:30:26 > top of Java-index,Java Essentials,New To Java...