By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,148 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,148 IT Pros & Developers. It's quick & easy.

Display a C++ window in a java GUI

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

bart59 wrote:
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


Jul 22 '05 #2

P: n/a
bart59 wrote:
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/...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
Jul 22 '05 #3

P: n/a
* Thomas Weidenfeller <no****@ericsson.invalid> schriebt:
bart59 wrote:
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.


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

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #4

P: n/a
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.
Jul 22 '05 #5

P: n/a
There exists no such thing as a C++ window.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
To iterate is human, to recurse divine.
-L. Peter Deutsch
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.