嗨,我正在尝试创建一个简单的脚本,将图像添加到我的墙纸文件夹中。到目前为止,它能够借助系统任务栏吐出简单的通知,我还能够在任务栏图标中添加选项/按钮,但是我想要的是在实际的通知中显示这些选项,而不是图标。
我得到了什么:
private static void displayTray(File file) throws AWTException {
PopupMenu trayPopupMenu = new PopupMenu();
Image image = Toolkit.getDefaultToolkit().createImage(SYSTEMTRAY_ICON);
TrayIcon trayIcon = new TrayIcon(image, "New Wallpaper", trayPopupMenu);
trayIcon.setImageAutoSize(true);
MenuItem open = new MenuItem("Open in Photos");
open.addActionListener(e -> {
Desktop dt = Desktop.getDesktop();
try {
dt.open(file);
} catch (IOException ex) {
tray.remove(trayIcon);
}
tray.remove(trayIcon);
});
trayPopupMenu.add(open);
MenuItem close = new MenuItem("Close");
close.addActionListener(e -> tray.remove(trayIcon));
trayPopupMenu.add(close);
trayIcon.setToolTip(null);
tray.add(trayIcon);
trayIcon.displayMessage("New Wallpaper", file.getName(), MessageType.INFO);
}
我已经看到了带有选项的通知,因此可以完成此操作,不确定如何操作