Şu satırı dahil ederiz
displayMessage metoduimport java.awt.SystemTray;
Şöyle yaparız
String toolTip = "...";if (SystemTray.isSupported()) {SystemTray tray = SystemTray.getSystemTray();TrayIcon[] trayIcons = tray.getTrayIcons();for (TrayIcon trayIcon: trayIcons ) {if (trayIcon.getToolTip().equals(toolTip)) {tray.remove(trayIcon);}}//If the icon is a file : e.g src/main/resources/2_1.jpgImage image = Toolkit.getDefaultToolkit().createImage("2_1.jpg");//Alternative (if the icon is on the classpath)://Image image = Toolkit.getDefaultToolkit().createImage(getClass().getResource("icon.png"));TrayIcon trayIcon = new TrayIcon(image, toolTip);//Let the system resize the image if neededtrayIcon.setImageAutoSize(true);//Set tooltip text for the tray icontray.add(trayIcon);trayIcon.displayMessage("...", TrayIcon.MessageType.INFO);}
Hiç yorum yok:
Yorum Gönder