IXTR Unai
IXTR Unai

Reputation: 377

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".

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);
}

enter image description here

Upvotes: 9

Views: 2649

Answers (2)

AUPMA
AUPMA

Reputation: 304

"Java(TM) Platform SE binary" doesn't appear if you use TrayIcon.MessageType.NONE

Example Image:

enter image description here

Upvotes: 1

Mordechai
Mordechai

Reputation: 16204

The only way to solve this is to use a java native launcher.

My best choice would be javapackager which allows you to bundle a local copy of the JVM to make your app completely portable.

Other option is launch4j which just creates a launcher but still requires Java installed.

Upvotes: 0

Related Questions