Windows 10では、画面の右下に通知があり、非常に便利です。JavaでWindows通知を作成する方法
JavaでWindows通知を作成する方法はありますか?
import java.awt.*;
import java.awt.TrayIcon.MessageType;
import java.net.MalformedURLException;
public class TrayIconDemo {
public static void main(String[] args) throws AWTException, MalformedURLException {
if (SystemTray.isSupported()) {
TrayIconDemo td = new TrayIconDemo();
td.displayTray();
} else {
System.err.println("System tray not supported!");
}
}
public void displayTray() throws AWTException, MalformedURLException {
//Obtain only one instance of the SystemTray object
SystemTray tray = SystemTray.getSystemTray();
//If the icon is a file
Image image = Toolkit.getDefaultToolkit().createImage("icon.png");
//Alternative (if the icon is on the classpath):
//Image image = Toolkit.getToolkit().createImage(getClass().getResource("icon.png"));
TrayIcon trayIcon = new TrayIcon(image, "Tray Demo");
//Let the system resize the image if needed
trayIcon.setImageAutoSize(true);
//Set tooltip text for the tray icon
trayIcon.setToolTip("System tray icon demo");
tray.add(trayIcon);
trayIcon.displayMessage("Hello, World", "notification demo", MessageType.INFO);
}
}
一つの質問を使用して、JDK 1.8で私の作品、私が見てきましたカスタムpngファイルのアイコンとして他の通知。 –
これは可能なようには見えません。これはAWTでは利用できない機能のようですが、ネイティブウィンドウのguiツールキットでのみ利用可能です。 – RAnders00
現在、アクションセンターの有効期限が切れた後、通知がアクションセンターから削除されます。そこに保管する方法はありますか? – Blaine