🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #18348

Re: JOptionPane Problem - Need Help!

#18348
From: Gerry Mantha
Date: Sun, 12 Jul 1998 00:00
52 lines
2910 bytes
Hi Jennifer,

I can't pretend to know what's going on here, but I think I can help you
solve your little problem.  First, as I mentioned in a previous posting, use
frame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
after creating your frame so you can take control when the user later
answers your dialog.  Now, I have also found that poping up JDialogs of any
sort during InternalFrame events causes lots of problems.  Why?  Who knows.
I figure this is just one of Swing's BUGS... errr I mean features


So, in order to show a dialog to get response for closing JInternalFrames I
use the "Internal" variety of dialogs offered in JOptionPane.  In your
example, just change JOptionPane.showMessageDialog(...) with
JOptionPane.showInternalMessageDialog(...).  Also, the first parm should be
the instance of the particular InternalFrame that's being closed, so just
get a reference by using the Event.getSource() and cast it to
JInternalFrame.  Here's the changes from the exampe you gave:

JOptionPane.showInternalMessageDialog((JInternalFrame) e.getSource(), "Close
Window", null, JOptionPane.INFORMATION_MESSAGE);
// you would normally check the user's selection from the dialog here
then...
((JInternalFrame) e.getSource()).dispose();

You may not be completely happy with the InternalDialogs.  They aren't
"completely" modal.  If you aren't, you may have to get a bit more
complicated and use the myJOptionPane.createInternalFrame(...)  to get a
reference to your InternalDialog Frame so that you can get more control.
(Add focus listeners, and such).

Hope this helps!

Gerry Mantha


Jennifer Merkel wrote in message <35A66773.40784ECA@EdmundsAssoc.com>...
>I am having a problem with JOptionPane & JInternalFrame. I have a
>JInternalFrame in  my app.  When it is closed I want to display a
>JOptionPane which will have three choices(yes/no/cancel).  The problem I
>am having is that my application locks up when I select an option
>usually the yes option for that app.  I also made a much smaller app to
>seeif I could isolate the problem and all three options hang the app at
>different times.  Sometimes it crashes after displaying once sometimes
>after ten times, it is very inconsistent.  Does anyone have any ideas as
>to what might be going on here?  Has any one gotten this type of
>scenario to work?
>
>Thanks in advance.
>
>Jennifer
>
Technical Details
Message-ID: <6ob5md$t5a2@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <35A66773.40784ECA@EdmundsAssoc.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,744e84584b0eef32
X-Google-Attributes: gidf74b3,public
From: "Gerry Mantha" <gmantha@home.com>
Subject: Re: JOptionPane Problem - Need Help!
Date: 1998/07/12
Message-ID: <6ob5md$t5a2@forums.borland.com>
X-Deja-AN: 370796143
References: <35A66773.40784ECA@EdmundsAssoc.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.1
Organization: QTECH Hybrid Systems Inc.
Newsgroups: borland.public.jbuilder.java.language