public static @NotNull JButton createJButtonForAction(@NotNull Action action, @Nullable JRootPane rootPane) {
    JButton button;
    if (action instanceof OptionAction optionAction && Registry.is("ide.allow.merge.buttons", true)) {
      JBOptionButton optionButton = new JBOptionButton(optionAction, optionAction.getOptions());
      optionButton.setOptionTooltipText(getDefaultTooltip());
      button = optionButton;
    }
    else {
      button = action instanceof DialogWrapperAction ? new JButton(action) : new JButton(action) {
        @Override
        protected void fireActionPerformed(ActionEvent event) {
          Window window = ComponentUtil.getWindow(this);
          DialogWrapper wrapper = window instanceof DialogWrapperDialog dwd ? dwd.getDialogWrapper() : null;
          if (wrapper != null && (wrapper.myClosed || wrapper.myPerformAction)) return;
          if (wrapper != null) wrapper.myPerformAction = true;
          try (AccessToken ignore = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) {
            super.fireActionPerformed(event);
          }
          finally {
            if (wrapper != null) wrapper.myPerformAction = false;
          }
        }
      };
    }

    if (SystemInfoRt.isMac) {
      button.putClientProperty("JButton.buttonType", "text");
    }

    Pair<Integer, @Nls String> pair = extractMnemonic(button.getText());
    button.setText(pair.second);
    int mnemonic = pair.first;

    Object value = action.getValue(Action.MNEMONIC_KEY);
    if (value instanceof Integer) {
      mnemonic = (Integer)value;
    }
    button.setMnemonic(mnemonic);

    if (action.getValue(DEFAULT_ACTION) != null) {
      if (rootPane != null) {
        rootPane.setDefaultButton(button);
      }
    }

    return button;
  }
public static @NotNull JButton createJButtonForAction(@NotNull Action action, @Nullable JRootPane rootPane)