0

I'm converting a C# windows forms application equivalent to a Java swing application and I'm stuck up at a position where I need to pass a window handle to C++ JNI layer.

In C++ layer, I've a function accepting void* pointer as window handle ie

void SetWindowHandle(void* handle);

In C#, it is simply done as:

obj.SetWindowHandle(videoPanel.Handle);//videoPanel is System.Windows.Forms.Panel

In Java, I've created the UI with JPanel instead of Windows.Forms.Panel, but I've no idea how to get the handle for this JPanel.

Any idea, how it can be done? JFYI, this window handle is used in lower C++ layer as a handle for rendering video.

HRM
  • 2,097
  • 6
  • 23
  • 37
  • They use the handle from their JFrame – online Thomas Oct 19 '15 at 11:53
  • @Thomas Cud u giv some more details..specifically is there any direct property or method available to get handle of JPanel/JFrame? – HRM Oct 19 '15 at 12:01
  • 1
    I'm not really up to speed, but this will probably answer your question: http://stackoverflow.com/questions/386792/in-java-swing-how-do-you-get-a-win32-window-handle-hwnd-reference-to-a-window – online Thomas Oct 19 '15 at 12:06

1 Answers1

0

I got this issue resolved by referring to this SO Post mentioned by Thomas in comment section.

One point to be noted is that, to get this method works, you need to use java.awt.Panel instead of javax.swing.JPanel as this was the mistake I done and wasted one single day!

Community
  • 1
  • 1
HRM
  • 2,097
  • 6
  • 23
  • 37