Display a C++ window in a java GUI

B

bart59

Hi,

I've got a java program and a c++ one.

The Java program`s output is a GUI, using swing and awt componants.

THe Cpp program is a 3D engine: OSG, Open Scene Graph., displaying a
3D model in the screne, with interaction : so that the user can move
on the scene, thanks to the mouse or keyboard.

Actually the Java is used as a command panel fot the 3Dengine.

I would like to know if i can have the Cpp ouput window (the 3D ouput
form the OSG cpp)
in a Java componant > frame or anything : so that I would be able to
keep all my software in only one main GUI.

I heard about python to solve my problem if JNI can't, but is it
possible to do this in Python ?
What can give me Python that Java can´t ?
Could nt be more difficult to use a third language ?

Thanks for you help !

Bart
 
P

perry

myself i wouldn't really think of Python for anything but parsing
strings and databases for which it was designed. always use the right
tool for the right job. as for a C++ GUI window inside Java, JNI should
be able to help you out there. if not you can give JMF a whirl, it was
designed to interface with all sorts of image rendering devices both in
and out.... should be a no brianer provided you find an appropaite JMF
example to go by....

- perry
 
T

Thomas Weidenfeller

bart59 said:
I would like to know if i can have the Cpp ouput window (the 3D ouput
form the OSG cpp)
in a Java componant > frame or anything : so that I would be able to
keep all my software in only one main GUI.

Well, if your C++ part renders the data on an own window or region of
the native operating system, then I would not do it. Little to nothing
is known about how to integrate a native window into a Java frame.
There is no public API available in Java to "merge" an entirely native
component with a Java container. So you would have to do some extensive
source code study. You need to get the complete source code from Sun,
especially the native C part, which is not packed with the Java SDK
(AFAIK available with a special license from Sun). Examining the
implementation of the native peer of java.awt.Canvas for your platform
would be a good start.

If your C++ code just provides the data, then you could use JNI to
render the data on a Java component like Canvas. An example is given in
http://java.sun.com/j2se/1.4.2/docs/guide/awt/1.3/AWT_Native_Interface.html
including some C and Java code.

Another alternative would be to consider re-writing the C++ part in
Java, and taking advantage of the existing 3D systems for Java.
Check comp.lang.java.3d


/Thomas
 
A

Alf P. Steinbach

* Thomas Weidenfeller said:
Well, if your C++ part renders the data on an own window or region of
the native operating system, then I would not do it. Little to nothing
is known about how to integrate a native window into a Java frame.
There is no public API available in Java to "merge" an entirely native
component with a Java container.

<ot>
The above is incorrect.
</ot>
 
B

bart59

But JAWT should be able to render such a C++ window no ?

I thought the main problem would come from the mouse interaction on
the java canvas containing the C++ renderer...

Sun give some exemples displaying an OpenGl engine in C++ in a Java
window.
 
P

Prateek R Karandikar

There exists no such thing as a C++ window.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
To iterate is human, to recurse divine.
-L. Peter Deutsch
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top