I want to display a tray notification using Java like the notifications that comes out in windows when disk space is low, there is no antivirus software etc.
Exactly like this.
I want to display a tray notification using Java like the notifications that comes out in windows when disk space is low, there is no antivirus software etc.
Exactly like this.
I'm thinking maybe you should have a look at TrayIcon.displayMessage
The only other way I know to achieve what you want, is via JNI
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Image img = null;
try {
img = ImageIO.read(new File("..."));
} catch (IOException e) {
e.printStackTrace();
}
TrayIcon ti = new TrayIcon(img, "Tooltip");
try {
// You need to add it to the system tray first
SystemTray.getSystemTray().add(ti);
} catch (AWTException ex) {
ex.printStackTrace();
}
ti.displayMessage("Low Disk Space", "Diskspace is very low",
MessageType.WARNING);
}
});