🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1273

Adding an exit confirmation dialog to a JFrame

#1273
From: Ron
Date: Thu, 11 Mar 2004 21:02
49 lines
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
Technical Details
Message-ID: <4050d3d3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!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

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,e0ae65b09d87ff96,start
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
Subject: Adding an exit confirmation dialog to a JFrame
Date: Thu, 11 Mar 2004 16:02:13 -0500
Lines: 51
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: <4050d3d3$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1079038931 161.233.20.179 (11 Mar 2004 13:02:11 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!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