Thread View: borland.public.jbuilder.java.swing
1 messages
1 total messages
Started by Ron
Thu, 11 Mar 2004 21:02
Adding an exit confirmation dialog to a JFrame
Author: Ron
Date: Thu, 11 Mar 2004 21:02
Date: Thu, 11 Mar 2004 21:02
49 lines
2178 bytes
2178 bytes
I have a JFrame (Frame1) and in the constructor, I want to provide for an
exit confirmation dialog. I add the code as follows:
public class Frame1 extends JFrame implements WindowConstants {
public Frame1() {
super ("Focus Frame");
//Code left out
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE ) ;
WindowAdapter a = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
int confirm = JOptionPane.showOptionDialog(Frame1, "Really
exit?",<---ERROR HERE
//--->>>Error is: "Frame1.java": Error #: 300 : variable Frame1 not found in
anonymous class of constructor Frame1()
//-->>>I UNDERSTAND why this is occurring, but how can I remedy it?
"Exit Confirmation",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (confirm == 0) {
//Frame1.dispose();
System.exit(0);
} //if
}
};//new
//Frame1.windowDeactivate();
addWindowListener(a);
Thanks
RON
_________________________________________________________
Black and White Photography: http://www.ronaldgansphotography.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads