The IntelliJ implementation might prove helpful:
https://github.com/JetBrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/ui/SystemTrayNotifications.java