The Java language provides support for creating a popup notification with icon ad message. This can be done using many libraries in Java. Here I am going to demonstrate a simple way using AWT SystemTray.
SystemTray class in Java:
The SystemTray class represents the system tray for a desktop. On Microsoft Windows it is referred to as the "Taskbar Status Area", on Gnome it is referred to as the "Notification Area", on KDE it is referred to as the "System Tray". The system tray is shared by all applications running on the desktop. On some platforms the system tray may not be present or may not be supported, in this case SystemTray.getSystemTray() throws UnsupportedOperationException. To detect whether the system tray is supported, use SystemTray.isSupported() method which returns true is it is supported.
For example:
if (SystemTray.isSupported()) {
System.out.println("System tray supported for this one!");
} else {
System.out.println("System tray not supported for this one!");
}
System.out.println("System tray supported for this one!");
} else {
System.out.println("System tray not supported for this one!");
}
The following snippet demonstrates how to create a System tray notification with icon :
For the full source code of this please visit my github url https://github.com/SubashJanarthanan/SystemTray
For the full source code of this please visit my github url https://github.com/SubashJanarthanan/SystemTray
Comments
Post a Comment