0

When making a Windows 10 notification how do I put a custom picture? I'm a fairly new coder and wanted to try making a notification program, what I'm trying to do is to make a program to notify me when I use OBS's replay buffer to record a clip and want it to pop up with a notification confirming a clip was saved that has the name of the clip saved in the body of the notification and then when I click it brings me to the clip's folder location. To start off here's my code for just the notification part:

import java.awt.*;
import java.awt.TrayIcon.MessageType;

public class OBSNotif {

    public static void main(String[] args) throws AWTException {
        if (SystemTray.isSupported()) {
            OBSNotif td = new OBSNotif();
            td.displayTray();
        } else {
            System.err.println("System tray not supported!");
        }
    }

    public void displayTray() throws AWTException {
        SystemTray tray = SystemTray.getSystemTray();


        Image image = Toolkit.getDefaultToolkit().createImage(getClass().getResource("icon.png"));

        TrayIcon trayIcon = new TrayIcon(image, "OBS");
        trayIcon.setImageAutoSize(true);
        trayIcon.setToolTip("OBS save notification");
        tray.add(trayIcon);

        trayIcon.displayMessage("OBS", "INSERT VIDEO ID" + " has been saved", MessageType.NONE);
    }
}

The result of the code is something like this:

https://i.stack.imgur.com/cbWw6.png

and the icon is just put into the system tray

but how can I have the icon in the notification like something like this?

https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSX3pYoQ9Bxl7R5P3dM6s2wZc9vsgHbFGasulMKcKMws81J5AURcQ&s

While on the subject how would I set up a listener for when I click on the notification to open an explorer window of a folder or fetch the name of the most recently added video to the folder where the clips are saved?

Chrisb
  • 1
  • The docs say the following: "The message type determines which icon will be displayed in the caption of the message, and a possible system sound a message may generate upon showing." https://docs.oracle.com/javase/7/docs/api/java/awt/TrayIcon.MessageType.html – Quadrivics Dec 13 '19 at 08:24
  • 1
    RIght i get that, but I'm trying to get a custom icon. – Chrisb Dec 13 '19 at 20:20

0 Answers0