posted 13 years ago
If I understand the blog correctly, there is a message sent by Windows (the OS) to all existing windows whenever the Explorer starts and creates a new taskbar. To receive these messages, you need a window handle. Though the JVM undoubtedly creates some windows to integrate running application into the OS, you probably won't be able to get handles of these windows, nor process the messages OS sends to them.
Assuming there is no native way to handle this from Java (which I honestly don't know), a possible way would be to program a DLL and use it to create a hidden window at application startup. This window would process the WM_TASKBARCREATED message. Even though a callback from DLL to Java is probably possible, I personally would just set a flag in the DLL upon receiving this message and use a timer to poll this flag time from time (say, once per second). If the Explorer just crashed, waiting a second for the icon to get resurrected is not a bad deal. Also, before the application exits, the DLL's window should be destroyed. Some thoughts should be also given to the possibility of multiple clients of the DLL (one DLL window could serve multiple JVMs), but we're getting quite stretched already.
It's a looooong time since I was doing DLLs and Windows development in C, so I can't go into greater detail here, but in my opinion this should be viable. However, you do need some experience with DLLs and JNA/JNI in Java.