简体   繁体   English

来自 Java 的 Windows 10 通知

[英]Notifications on Windows 10 from Java

I'm creating a Java program which pushes notifications and I want to remove or edit the line which says "Java(TM) Platform SE binary".我正在创建一个推送通知的 Java 程序,我想删除或编辑显示“Java(TM) Platform SE 二进制文件”的行。

Is this possible?这可能吗? I searched on google but I couldn't see info about this.我在谷歌上搜索,但我看不到有关此的信息。

Here is the related code.这是相关的代码。 The last line is the line that pushes the notification.最后一行是推送通知的行。

public void mostrarNotificacion(Usuario user) throws AWTException, java.net.MalformedURLException, IOException {
    //Obtain only one instance of the SystemTray object
    SystemTray tray = SystemTray.getSystemTray();

    //Get image
    BufferedImage trayIconImage = ImageIO.read(getClass().getResource("favicon.png"));
    int trayIconWidth = new TrayIcon(trayIconImage).getSize().width;
    TrayIcon trayIcon = new TrayIcon(trayIconImage.getScaledInstance(trayIconWidth, -1, Image.SCALE_SMOOTH));

    //Let the system resizes the image if needed
    trayIcon.setImageAutoSize(true);

    //Set tooltip text and notification text
    if(user.getDescargos()>=5 || user.getOtrosPendientes()>=1){
        mensaje = "Descargos pendientes: " + user.getDescargos() + "\nSecciones pendientes: "+ user.getOtrosPendientes();
    }
    trayIcon.setToolTip(mensaje);
    tray.add(trayIcon);
    trayIcon.displayMessage("Pendientes EKHI", mensaje, MessageType.WARNING);
}

在此处输入图片说明

"Java(TM) Platform SE binary" doesn't appear if you use TrayIcon.MessageType.NONE如果您使用TrayIcon.MessageType.NONE则不会出现“Java(TM) Platform SE 二进制文件”

Example Image:示例图像:

在此处输入图片说明

The only way to solve this is to use a java native launcher.解决此问题的唯一方法是使用 Java 本机启动器。

My best choice would be javapackager which allows you to bundle a local copy of the JVM to make your app completely portable.我最好的选择是javapackager ,它允许您捆绑 JVM 的本地副本,使您的应用程序完全可移植。

Other option is launch4j which just creates a launcher but still requires Java installed.另一个选项是launch4j ,它只是创建一个启动器,但仍需要安装 Java。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM