🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Adding an exit confirmation dialog to a JFrame

#1134
From: Ron
Date: Fri, 12 Mar 2004 14:11
85 lines
4223 bytes
Thanks!! Greatly appreciated.

RON
"Kevin Dean" <NkOdSePaAnM@datadevelopment.com> wrote in message
news:4051c114@newsgroups.borland.com...
> That's true, the dialog is modal, but there are cases where, if the parent
> frame is null, you can still bring Frame1 to the foreground, even though
> nothing else (menus, buttons, etc.) will respond.  It can be a real
nuisance
> for users, so you should always, wherever possible, assign a parent to a
> dialog.
>
> -- 
> Check out our latest white papers at
> http://www.datadevelopment.com/papers/index.html
>
> BladeNET Scores With Borland Enterprise Tools
> Team Development with JBuilder and Borland Enterprise Server
>
> Dolphin Data Development Ltd.
> http://www.datadevelopment.com/
>
> "Ron" <rgans@nospamRonaldgansphotographyDOTcom> wrote in message
> news:4051bcf9$1@newsgroups.borland.com...
> > Admittedly, I am a novice at this (but a C++ and VB programmer for about
> 20
> > years), so  I may be doing something wrong, but I just tried it and the
> > JOptionPane was definitely modal to the the Frame:
> >
> > here's the code I wrote:
> >
> >
> > public class Frame1 extends JFrame implements WindowConstants {
> >   //Construct the frame
> >   public Frame1() {
> >     super ("Focus Frame");
> >     setSize(400,400);
> > //...code where a series of JInternalFrames are created is omitted....
> >
> >  WindowAdapter a = new WindowAdapter() {
> >       public void windowClosing(WindowEvent e) {
> >         int confirm = JOptionPane.showOptionDialog(null, "Really exit?",
> >             "Exit Confirmation",
> >             JOptionPane.YES_NO_OPTION,
> >             JOptionPane.QUESTION_MESSAGE,
> >             null, null, null);
> >         if (confirm == 0) {
> >           //Frame1.dispose();
> >           System.exit(0);
> >         }
> >       }
> >     };
> >
> >   addWindowListener(a);
> >  }
> >   public static void main (String[] args) {
> >     Frame1 frame = new Frame1();
> >     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> >     frame.setBounds(0,0,600,450);
> >     frame.setVisible(true);
> >   }
> >
> > When I run this, and try to exit (via the Java cup icon in the top left)
> the
> > exit dialog is definitely modal.
> >
> > RON
> >
> > "Tor Iver Wilhelmsen (TeamB)" <tor.wilhelmsen@ergo.no> wrote in message
> > news:u8yi632td.fsf@ergo.no...
> > > "Ron" <rgans@nospamRonaldgansphotographyDOTcom> writes:
> > >
> > > > Thanks! I tried it and it worked, but then the question: I used null
> and
> > > > that worked also. Both Frame1.this and null seem to have the same
> > > > functionality, in this very tiny example.
> > >
> > > It does - until you bring the frame to the foreground. If you have
> > > passed the frame to JOptionPane, the modal dialog will then pop to the
> > > foreground; otherwise the modal dialog remains in the background and
> > > the user will not know why they can\t interact with the frame.
> >
> >
>
>
Technical Details
Message-ID: <4051c51d$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4050d3d3$1@newsgroups.borland.com> <4050d4ef@newsgroups.borland.com> <4050dce5@newsgroups.borland.com> <u8yi632td.fsf@ergo.no> <4051bcf9$1@newsgroups.borland.com> <4051c114@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-12 06:37:54 PST
Reply-To: "Ron" <rgans@nospamRonaldgansphotographyDOTcom>
From: "Ron" <rgans@nospamRonaldgansphotographyDOTcom>
Newsgroups: borland.public.jbuilder.java.swing
References: <4050d3d3$1@newsgroups.borland.com> <4050d4ef@newsgroups.borland.com> <4050dce5@newsgroups.borland.com> <u8yi632td.fsf@ergo.no> <4051bcf9$1@newsgroups.borland.com> <4051c114@newsgroups.borland.com>
Subject: Re: Adding an exit confirmation dialog to a JFrame
Date: Fri, 12 Mar 2004 09:11:43 -0500
Lines: 87
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: <4051c51d$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1079100701 161.233.20.179 (12 Mar 2004 06:11:41 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail