Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6553366

Public API for Obtaining a Native Window



    • Type: Enhancement
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 7
    • Fix Version/s: tbd
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
    • OS:



      Public API for Obtainin a Native Window

      The office bean (class com.sun.star.comp.beans.OOoBean) is a Java class that allows to show and modify ODF documents within a Java application. It utilizes the native window which is used by the class java.awt.Canvas. It is obtained by using a JNI call into native code, where it is obtained as explained in “The AWT Native Interface” (http://java.sun.com/javase/6/docs/technotes/guides/awt/AWT_Native_Interface.html).
      The difference to the example in the documentation is that the window id or window handle (JAWT_DrawingSurfaceInfo.drawable or JAWT_Win32DrawingSurfaceInfo.hwnd ) is returned from the function. The handle is then passed on to the office which uses it as parent window for the office window. The code which passes the handle to the office is written completely in Java.

      What we like to achieve is a documented and supported way of getting and using the window id / handle. This is not in the scope of the documentation of the “AWT Native Interface” and it is declared as unsupported in the JNI FAQ (http://java.sun.com/products/jdk/faq/jni-j2sdk-faq.html#windowid).

      This documentation and possible API change / addition should be in a way so that Java versions from different vendors can implement it as well.

      The API must also provide the information about particular protocols which need to be complied with. Currently there is only the XEmbed protocol which I know of and which needs special handling. The window id / handle could transport this information as window property. If this protocol is indicated, then it should be usable right away. That is, it should not be necessary to start the VM with a property, such as sun.awt.xembedserver=true.

      At least in the scenario of the office bean it would make sense to offer a Java API. Then it could use a public API, which could also be provided by other Java vendors. This API should provide the window id / handle and additional information about particular protocols which need to be used.

      It is also desirable to have a notification mechanism, which indicates that the native window of the Java window is about to be destroyed. This gives the office the chance to terminate its window in an “ordered” way. Currently the office bean overrides Canvas.removeNotify to get this notification. If this is a feasible way for the future then the documentation of this method should be updated accordingly.




            serb Sergey Bylokhov
            duke J. Duke (Inactive)
            0 Vote for this issue
            2 Start watching this issue