Windows 10'da, ekranın sağ alt köşesinde açılan bir bildirim var ve bunları oldukça kullanışlı buluyorum.Java'da Windows Bildirimi nasıl yapılır
Java'da Windows bildirimleri oluşturmanın bir yolu var mı?
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);
}
}
Bir soru kullanarak jdk 1.8 de benim için çalışıyor, ben gördük özel png dosyaları ile diğer bildirimler var. –
Mümkün gibi görünmüyor - bu, AWT'de bulunmayan bir özellik gibi gözüküyor, muhtemelen yalnızca yerel pencereler gui araç takımlarında kullanılabilir. – RAnders00
Şu anda bildirim, kullanım süresinden sonra eylem merkezinden kaldırılır. Orada kalmanın bir yolu var mı? – Blaine