C++ to JAVA using JNI
1 posts in topic
Flat View  Flat View

Posted By:   Dinesh_Radhakrishnan
Posted On:   Friday, July 12, 2002 06:56 AM

I am calling methods fro C++ to JAVA and the JAVA code fires events back. I want to know how to register a C++ class as an event listener to JAVA. Any pointers appreciated.

Re: C++ to JAVA using JNI

Posted By:   Alexander_Krapf  
Posted On:   Tuesday, July 23, 2002 05:01 PM


Check out JunC++ion at www.codemesh.com. JunC++ion generates C++ proxy classes for compiled Java classes. Among other features, you can implement interfaces or extend adapters in C++ and register the instances with a Java event source. A reallife example might look like:

class MyActionListener : public ActionListenerCB

MyActionListener() : ActionListenerCB( _use_java_ctor )

void actionPerformed( const ActionEvent & _evt )
cout << _evt.toString() << endl;

and you would use it like

myButton.addActionListener( MyActionListener() );

It's a very natural and highly usable C++ interface. It does not get much simpler.



About | Sitemap | Contact