问题
Is it possible to get the pointer or the window number of the underlying NSWindow of a JComponent on Mac, using JNA. I found methods getWindowID and getWindowPointer in com.sun.jna.Native. The documentation mentions getWindowID is for X11 and getWindowPointer is for win32. Is there a similar function for Mac OSX ?? I know how to get the cocoa window of a component using a JNI function but I am interested in using something in Java without writing a JNI function.
-Thanks, Abhinay.
回答1:
If you know how to do it in jni, then you most probably can do it with JNA. But, you would have to create your own mapping to cocoa libraries or see if rococoa already has what you need.
回答2:
getWindowPointer()
does the same thing for Mac OSX (it returns a pointer corresponding to the cocoa view ref). You may have to do additional manipulations to get a reference to the exact reference you need; as Denis suggests, rococoa likely has some utilities that would provide useful.
来源:https://stackoverflow.com/questions/12057817/using-jna-to-get-nswindow-from-jcomponent-on-mac