Is it possible to display notifications with custom icon in Windows 10 with Java?

3

I know how to do this kind of notifications:

But it turns out that it only changes the icon when changing the message type:

trayIcon.displayMessage("Titulo", "Contenido", TrayIcon.MessageType.INFO);

It's the only thing I could find on the internet, do you have any idea what you could do?

Here I leave the code of the TrayIcon with which I use the displayMessage ():

public void IconoBandeja(){

    if(!SystemTray.isSupported()){
        System.out.println("We can't show the Tray Icon");
    }

    final PopupMenu popup = new PopupMenu();
    trayIcon = new TrayIcon(CreateIcon("/img/logo.jpg", "Administrador de clientes"));
    trayIcon.setImageAutoSize(true);
    final SystemTray tray = SystemTray.getSystemTray();
    //trayIcon.setToolTip("Version 1.6.21\nProject Jarvis");

    //Add components/ Menu items
    MenuItem AboutItem = new MenuItem("About");
    MenuItem ExitItem = new MenuItem("Exit");

    //Populate the pop up menu
    popup.add(AboutItem);
    popup.addSeparator();
    popup.add(ExitItem);

    trayIcon.setPopupMenu(popup);

    AboutItem.addActionListener(new ActionListener() 
    {
        @Override
        public void actionPerformed(ActionEvent e) 
        {
            trayIcon.displayMessage("Titulo", "Contenido", TrayIcon.MessageType.INFO);
        }
    });

    try 
    {
        tray.add(trayIcon);
    }catch (AWTException e) 
    {

    }
}
    
asked by Extibax 21.10.2018 в 04:57
source

1 answer

2
  

It is possible to display notifications with custom icon - TrayIcon ?

Putting your type of message to NONE , will put as an icon the image passed as an argument to TrayIcon

TrayIcon.MessageType.NONE

The complete call to the displayMessage method within actionPerformed

trayIcon.displayMessage("Titulo", "Contenido", TrayIcon.MessageType.NONE);

This would be the case in my particular case ..

    
answered by 22.10.2018 / 06:40
source