简体   繁体   中英

Display C++ program in Java

I'm new to JNI and just started learning it.

I have successfully executed a graphical C++ program in java using JNI . Now i want to try something more advanced which is display that C++ graphical program within JFrame or JPanel.

Is it possible and how to do it ? Ideally it would be something like this

Thanks for answering and sorry if my question is vague.

Edit : This is quite similiar to my question Display a C++ window in a java GUI

Theoretically that should be possible, although not with JFrame/JPanel. Swing is peerless, and you'd have to use a heavyweight component as the parent for your UI. But everything you do there is highly not-portable and it involves JRE internal classes, so if you really get this done it might break with another JRE version. And you might run into weird problems with event handling.

As a starter you could look at what the Eclipse SWT_AWT bridge is doing. Essentially they're doing what you describe, embed something that's not AWT in an AWT Canvas.

I think I've found a solution from Embed OpenGL inside Java AWT Canvas . Someone please correct me if this is not related.

Thank you Jim and user2543253 for your help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM