30 lines
945 B
Java
30 lines
945 B
Java
package eu.mikroskeem.notificationhackery.windows;
|
|
|
|
import eu.mikroskeem.notificationhackery.INotificationBackend;
|
|
|
|
import java.awt.*;
|
|
|
|
public class WindowsNotification implements INotificationBackend {
|
|
private final SystemTray tray;
|
|
private final TrayIcon trayIcon;
|
|
|
|
public WindowsNotification() throws Exception {
|
|
if (!SystemTray.isSupported()) {
|
|
throw new Exception("System tray not supported!");
|
|
}
|
|
tray = SystemTray.getSystemTray();
|
|
Image image = Toolkit.getDefaultToolkit().getImage((String)null);
|
|
trayIcon = new TrayIcon(image, "mikroskeem's haxx shit yo");
|
|
trayIcon.setToolTip("DON'T HOVER ON ME!!!");
|
|
tray.add(trayIcon);
|
|
}
|
|
|
|
@Override public void sendNotification(String title, String body) {
|
|
trayIcon.displayMessage(title, body, TrayIcon.MessageType.INFO);
|
|
}
|
|
|
|
@Override public void cleanup() {
|
|
tray.remove(trayIcon);
|
|
}
|
|
}
|