Jump to content
Excelsior Forums
Sign in to follow this  
swtM

Embedding JPanel in C++

Recommended Posts

Is there any possibility to embed a Java component (e.g. a JPanel or SWT Canvas) into a C++-MFC-Program by using a Java-DLL? So that the Java code is contained in the dll and the C++ program uses and integrates this dll.

Share this post


Link to post
Share on other sites

Sure.

Just check the samples:

<JET Installation directory>\samples\Invocation\cMain

<JET Installation directory>\samples\Invocation\attachCThread 

Share this post


Link to post
Share on other sites

Thank you for your reply.

As far as I understand these examples they are about integrating "normal" java code by a dll into a C(++) program.

I am especially interested in embedding a Java graphical component like a JPanel into the MFC-GUI. So my question is if it is possible to handle such a java graphical object like a normal MFC component within my user interface.

Share this post


Link to post
Share on other sites
I am especially interested in embedding a Java graphical component like a JPanel into the MFC-GUI.

As you refer to JPanel, we are talking about JFC/Swing which is a complete windowing system itself. I doubt that the Swing public API allows you to embed a Swing control into an MFC control - you should choose either.  B)

In general, you can display Swing controls from C++ apps but without the requirement to embed them into frames of another windowing system.

Share this post


Link to post
Share on other sites

Thanks again for your help.

Would it make any difference if SWT was used instead of Swing? This windowing system is based on native widgets. So there might be a way...?

Share this post


Link to post
Share on other sites
Would it make any difference if SWT was used instead of Swing? This windowing system is based on native widgets. So there might be a way...?

Only if you dive deep into the SWT internals...

Even though you will succeed, things may change with a next release of SWT because API vendors have in mind "typical use" of the API not "embeedding hacks" like the way of co-usage with MFC you mentioned.

Anyway, you may give a try with SWT

Share this post


Link to post
Share on other sites

About 2 years ago I was looking onto the same issue. Now I don't exactly remember the name of the tool, but, you can convert any Java Bean type component into an activeX control, therefore you can use it in a MFC application

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×