Display C++ program in Java

陌路散爱 提交于 2020-01-04 15:32:07

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/28979052/display-c-program-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!