How can I detect when new windows are opened and/or get a list of open windows?
I am aware of WindowListener
and its ilk, but these only seem to provide events for windows to which you have a reference already and can add the listener to. I'm wondering how to either receive a callback when new windows are created by other processes, or poll for a list of all windows currently open on the system.
I'm using J2SE on Mac OS X, but a cross-platform answer is ideal开发者_开发技巧.
Like already said above you can only monitor windows created by Java apps. Getting that kind of information would require OS specific development (JNI).
Window.getWindows();
Window.getOwnedWindows();
Window.getOwnerlessWindows();
But these are only Windows opened by your Java app.
I think that's not possible due to the sandbox idea behind the JRE. You can only "see" Windows from your own process. But I don't know for sure.
精彩评论