Dialogs
are more transitory. They're used for simple user input or for quick alerts to the user.
Like java.awt.Frame
, java.awt.Dialog
is a subclass of java.awt.Window
and hence of java.awt.Container
and java.awt.Component
. Therefore a lot of what you learned about frames applies to dialogs as well. You move them, resize them and add to them almost exactly as you do frames. There are two differences between dialogs and frames:
In the 1970's a computer virus worked its way into several early timesharing systems. The computer program would periodically break in on a user's session and say "I WANT A COOKIE." The terminal would then refuse to respond to any user input until the user typed the word "COOKIE" at which point the program would say something like "MMM, MMM, THAT WAS GOOD." and return control to the user.
Modal dialogs are a lot like the cookie monster program. They request input from the user and don't let anything else happen until they get it. Non-modal dialogs pop-up but they don't prevent the user from doing other things while they're visible. Because modal dialogs inconvenience users by forcing them to respond when the computer wants them to rather than when they want to, their use should be kept to a minimum.