code: public int showDialog(Component parent) {
          dialogResultValue = ERROR_OPTION;
          JDialog dialog = createDialog(parent);
          dialog.addWindowListener(new WindowAdapter() {
  
              @Override
              public void windowClosing(WindowEvent e) {
                  dialogResultValue = CANCEL_OPTION;
              }
          });
  
          dialog.setVisible(true);
          dialog.dispose();
          dialog = null;
  
          return dialogResultValue;
      }
docs: Show font selection dialog.
  @param parent Dialog's Parent component.
  @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
  
  @see #OK_OPTION
  @see #CANCEL_OPTION
  @see #ERROR_OPTION