@NotNull
 @Override
 public BalloonBuilder createHtmlTextBalloonBuilder(
     @NotNull String htmlContent, MessageType messageType, @Nullable HyperlinkListener listener) {
   return createHtmlTextBalloonBuilder(
       htmlContent, messageType.getDefaultIcon(), messageType.getPopupBackground(), listener);
 }
  public BalloonHandler notifyByBalloon(
      MessageType type,
      String htmlBody,
      @Nullable Icon icon,
      @Nullable HyperlinkListener listener) {
    final Balloon balloon =
        JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(
                htmlBody.replace("\n", "<br>"),
                icon != null ? icon : type.getDefaultIcon(),
                type.getPopupBackground(),
                listener)
            .createBalloon();

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            Component comp = InfoAndProgressPanel.this;
            if (comp.isShowing()) {
              int offset = comp.getHeight() / 2;
              Point point = new Point(comp.getWidth() - offset, comp.getHeight() - offset);
              balloon.show(new RelativePoint(comp, point), Balloon.Position.above);
            } else {
              final JRootPane rootPane = SwingUtilities.getRootPane(comp);
              if (rootPane != null && rootPane.isShowing()) {
                final Container contentPane = rootPane.getContentPane();
                final Rectangle bounds = contentPane.getBounds();
                final Point target = UIUtil.getCenterPoint(bounds, new Dimension(1, 1));
                target.y = bounds.height - 3;
                balloon.show(new RelativePoint(contentPane, target), Balloon.Position.above);
              }
            }
          }
        });

    return new BalloonHandler() {
      @Override
      public void hide() {
        SwingUtilities.invokeLater(
            new Runnable() {
              @Override
              public void run() {
                balloon.hide();
              }
            });
      }
    };
  }