Don't bury dialogs

The JDialog class uses the idea of an owner object. The owner is the class which is using the JDialog, either a Frame or another Dialog. It's possible to pass null as the owner, but that's a very bad habit. If no owner is defined, then various highly desirable behaviors are lost:

The last point may seem minor at first glance, but it's actually a major problem. When proper ALT+TAB behavior is absent, the dialog can easily get 'lost' behind your application. Many end users have no idea how to recover access to such lost dialogs. This becomes especially serious when the dialog is modal (which they usually are) since, not only can the user not find the dialog, but they are unable to interact with any other screens in the application. In this situation, many end users will naturally conclude that the application is hung, and they will do what they always do when an application is hung - they will reboot the machine.

This issue can be addressed in your Standard Dialog class, which may enforce the rule that an owner be specified.

As a backup style, your Standard Dialog might use the active frame as its owner, if none is explicitly passed by the caller. Here is a code snippet showing how to get the active frame.

import java.awt.Frame;

public final class ActiveFrame {

  /** Return the currently active frame. */
  public static Frame getActiveFrame() {
    Frame result = null;
    Frame[] frames = Frame.getFrames();
    for (int i = 0; i < frames.length; i++) {
      Frame frame = frames[i];
      if (frame.isVisible()) { 
        result = frame;
    return result;

See Also :
Standardized dialogs