code: public void setDialogMode(int mode) {
          if (!(mode == OK_CANCEL_DIALOG || mode == CLOSE_DIALOG)) {
              throw new IllegalArgumentException("invalid dialog mode");
          }
  
          if (okButton != null) {
              buttonPane.remove(okButton);
              okButton = null;
          }
          if (cancelOrCloseButton != null) {
              buttonPane.remove(cancelOrCloseButton);
              cancelOrCloseButton = null;
          }
  
          switch (mode) {
              case OK_CANCEL_DIALOG:
                  okButton
                          = new JButton(ResourceManager.all(BaseDialog.class).getString("ok"));
                  okButton.addActionListener(okAction);
                  buttonPane.add(okButton);
                  cancelOrCloseButton
                          = new JButton(
                                  ResourceManager.all(BaseDialog.class).getString("cancel"));
                  cancelOrCloseButton.addActionListener(cancelOrCloseAction);
                  buttonPane.add(cancelOrCloseButton);
                  getRootPane().setDefaultButton(okButton);
                  break;
              case CLOSE_DIALOG:
                  cancelOrCloseButton
                          = new JButton(ResourceManager.all(BaseDialog.class).getString("close"));
                  cancelOrCloseButton.addActionListener(cancelOrCloseAction);
                  buttonPane.add(cancelOrCloseButton);
                  break;
          }
  
          this.mode = mode;
      }
docs: Sets the mode of this dialog. Default mode is
  {@link BaseDialog#OK_CANCEL_DIALOG}
  
  @param mode {@link BaseDialog#OK_CANCEL_DIALOG}or
  {@link BaseDialog#CLOSE_DIALOG}