Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2006

Tip: Looking for answers? Try searching our database.

Java Dialog Modality Question

Thread view: 
swebb99@gmail.com - 18 Jul 2006 10:59 GMT
Hi,

I've got a question about modality of dialog's in Java and how this
relates to the parent of an dialog.

If I have a JFrame which has an associated JDialog which is displays if
I then want to display another dialog from the 1st dialog and also make
this modal should the 2nd dialog's parent be the 1st dialog or the
JFrame. I suppose what I am really asking is if I make a JDialog's
parent a JFrame will swing look after locking any other dialog's
associated with the frame.

If you have the make the 2nd dialog's parent the 1st this does mean
that for dialog's that can be displayed via a frame or other dialog
they will need multiple constructors so the parent can be either a
frame or a dialog.

Cheers

Steve
Steve W. Jackson - 18 Jul 2006 18:48 GMT
> Hi,
>
[quoted text clipped - 16 lines]
>
> Steve

At <http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Dialog.html> you'll
see the API Javadocs which contain the following statement:

A dialog can be either modeless (the default) or modal. A modal dialog
is one which blocks input to all other toplevel windows in the
application, except for any windows created with the dialog as their
owner.

So if the owner of your JDialog is the underlying JFrame rather than the
JDialog creating it, that's still going to block access to the creating
JDialog.  JDialog already has separate constructors for ownership by a
Dialog or Frame.

There's a hitch, though, that I've seen on Windows systems in some
situations.  If you switch applications, the wrong JDialog can sometimes
come to the top when you switch back, thus making it unclear why you
can't seem to interact with anything.  That is an operational reason for
doing what I consider the preferred way anyway, which is that every
modal JDialog should be owned by the one creating it and not some other
parent.  It makes the "hierarchy" more clear.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.