Article View: borland.public.jbuilder.java.swing
Article #1128Re: Adding an exit confirmation dialog to a JFrame
From: Ron
Date: Thu, 11 Mar 2004 21:05
Date: Thu, 11 Mar 2004 21:05
58 lines
2592 bytes
2592 bytes
FORGET IT (and sorry): I just realized I can pass a null in in place of the
Frame1 and it works perfectly.
RON
"Ron" <rgans@nospamRonaldgansphotographyDOTcom> wrote in message
news:4050d3d3$1@newsgroups.borland.com...
> 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
>
>
Technical Details
Message-ID:
<4050d484$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4050d3d3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,e0ae65b09d87ff96 X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2004-03-11 13:10:40 PST Reply-To: "Ron" <rgans@nospamRonaldgansphotographyDOTcom> From: "Ron" <rgans@nospamRonaldgansphotographyDOTcom> Newsgroups: borland.public.jbuilder.java.swing References: <4050d3d3$1@newsgroups.borland.com> Subject: Re: Adding an exit confirmation dialog to a JFrame Date: Thu, 11 Mar 2004 16:05:09 -0500 Lines: 60 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 161.233.20.179 Message-ID: <4050d484$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1079039108 161.233.20.179 (11 Mar 2004 13:05:08 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail