If you want to close/dispose a frame you need a reference to that frame. Is this done on the same frame you are talking about?

No sir i don,t want to close or dispose frame on Cancel option.Frame is close on Yes option.I want when user click on Cancel button then work still same.But in this code when i use cancel option without

In your code, even on the Yes option it can't work. See the code in Yes and Cancel options. There is no different. So what are you talking about, in any option you don't have handle any event on the frame.

In your code, even on the Yes option it can't work. See the code in Yes and Cancel options. There is no different. So what are you talking about, in any option you don't have handle any event on the frame.

In your code, even on the Yes option it can't work. See the code in Yes and Cancel options. There is no different. So what are you talking about, in any option you don't have handle any event on the frame.

Sir i create a even handel in frame class.Now i call it in main class..

Java Code:

protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
int exit = JOptionPane.showConfirmDialog(this, "Are you sure?");
if (exit == JOptionPane.YES_OPTION) {
System.exit(0);
}
} else {
// If you do not want listeners processing the WINDOW_CLOSING
// events, you could this next call in an else block for the:
// if (e.getID() ...)
// statement. That way, only the other types of Window events
// (iconification, activation, etc.) would be sent out.
super.processWindowEvent(e);
}
}

In your code, even on the Yes option it can't work. See the code in Yes and Cancel options. There is no different. So what are you talking about, in any option you don't have handle any event on the frame.

Hi
according to question you want to do the following:
1) when the user click on yes, An Application will open the browser say Yahoo! and exit
2) on clicking no button an Application will exit without opening the browser
and
3) on clicking cancel button that dialog box should be closed.