gpt4 book ai didi

java - 如何使气球通知中的 URL 可点击?

转载 作者:行者123 更新时间:2023-11-30 02:42:14 27 4
gpt4 key购买 nike

我正在创建一个简单的 IntelliJ 插件,允许直接从 IDE 创建新的 Pastebin 粘贴。

当粘贴成功发布到 Pastebin 时,我想显示一个气球通知。

目前通知显示如下:

final Response<String> postResult = Constants.PASTEBIN.post(paste);
NotificationGroup balloonNotifications = new NotificationGroup("Notification group", NotificationDisplayType.BALLOON, true);
if (postResult.hasError()) {
//Display error notification
} else {
//Display success notification
Notification success = balloonNotifications.createNotification("Successful Paste", "<a href=\"" + postResult.get() + "\">Paste</a> successfully posted!", NotificationType.INFORMATION, null);
Notifications.Bus.notify(success, project);
}

现在,此气球通知包含新创建的粘贴的 URL,但遗憾的是单击它不会在浏览器中打开该链接。如何才能实现这一目标?

带有应可点击的 URL 的气球通知: Balloon notification

最佳答案

有一个NotificationListener可以打开通知中的url:com.intellij.notification.UrlOpeningListener

所以你可以写:

Notification success = balloonNotifications.createNotification(
"<html>Successful Paste", "<a href=\"" + postResult.get() + "\" target=\"blank\">Paste</a> successfully posted!</html>",
NotificationType.INFORMATION, new NotificationListener.UrlOpeningListener(true));

关于java - 如何使气球通知中的 URL 可点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41298454/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com