import java.awt.*;
public class Test {
public static void main(String[] args) throws Exception {
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
java.awt.Image image = Toolkit.getDefaultToolkit().getImage("images/tray.gif");
TrayIcon trayIcon = new TrayIcon(image);
tray.add(trayIcon);
trayIcon.displayMessage("Test.", "This is a message to test notifications in Windows 10",
TrayIcon.MessageType.INFO);
}
}
信息量不大。这是一个类似的示例,但已尽可能简化:
}
下面是在IntellyJ IDEA开发环境运行后的截图,运行Java 8,Windows 10:
试试这个TrayNotification库,我想这就是你需要的