/**
  * Shows a modal font-chooser dialog and blocks until the dialog is hidden. If the user presses
  * the "OK" button, then this method hides/disposes the dialog and returns the selected color. If
  * the user presses the "Cancel" button or closes the dialog without pressing "OK", then this
  * method hides/disposes the dialog and returns <code>null</code>.
  *
  * @param parent the parent <code>Component</code> for the dialog
  * @param title the String containing the dialog's title
  * @return the selected font or <code>null</code> if the user opted out
  * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
  * @see java.awt.GraphicsEnvironment#isHeadless
  */
 public Font showFontDialog(Component parent, String title) {
   BaseDialog dialog = createDialog(parent, title);
   if (dialog.ask()) {
     return getSelectedFont();
   } else {
     return null;
   }
 }
  protected BaseDialog createDialog(Component parent, String title) {
    BaseDialog dialog;
    Window window =
        (parent == null ? JOptionPane.getRootFrame() : SwingUtilities.windowForComponent(parent));
    if (window instanceof Frame) {
      dialog = new BaseDialog((Frame) window, title, true);
    } else {
      dialog = new BaseDialog((Dialog) window, title, true);
    }
    dialog.setDialogMode(BaseDialog.OK_CANCEL_DIALOG);
    dialog.getBanner().setVisible(false);

    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.getContentPane().add("Center", this);
    dialog.pack();
    dialog.setLocationRelativeTo(parent);

    return dialog;
  }