If you look in the
Java API documentation, you'll see that the parentComponent field is documented as follows: -
parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
message - the Object to display
That basically tells you what you need to know. You're asking it to use a default Frame as the parent of your message dialog.
If your application is a console application, this could be appropriate. If it's an application with a Swing or AWT user interface, it is probably wrong;
you should be passing a parent component - perhaps the outermost Frame of your application.
Note that using the default Frame in this, or any other, Swing method call has an unpleasant side effect. Because this Frame is out of your control, it sticks around after the rest of your application has closed down. It can keep the Swing event processing
thread going and prevent your application from shutting down cleanly. You will find yourself having to use System.exit(), which is an ugly and bad way to exit a Java application. You can avoid this by always passing a component of your own as the parent of any component you create. You can create an invisible Frame of your own as the parent of anything that has no other obvious parent. When it is time to exit the application, make sure you dispose() this Frame.
By the way
UseAMeaningfulSubjectLine [ July 11, 2007: Message edited by: Peter Chase ]