JNI and event listeners in native code?

M

Martijn Tonies

Hi,

Does anyone know if it's possible to create java classes via
JNI from native code and then attach event listeners to, for
example, a java.awt.Button. The event handler should be in
native code.

If not, what would be the alternative? I was thinking of a
small Java class that implements the listener interface and
then the native code can create that class, attach it to the
button as an event listener and attach native methods to
the listener-implementing class. That should be possible,
right?



--
Martijn Tonies
Database Workbench Lite for MySQL - FREE developer tool for MySQL!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
 
R

Roedy Green

Does anyone know if it's possible to create java classes via
JNI from native code and then attach event listeners to, for
example, a java.awt.Button. The event handler should be in
native code.

ANY method could act as an event handler. So there is no problem
making it native or call native code.
see http://mindprod.com/jgloss/jni.html

The tricky part would be getting native code to generate events.

JNI is not for creating Java classes on the fly. It for letting you
access C++ classes.

To create code on the fly and compile it into Java classes, which you
could then use in any way you please, see
http://mindprod.com/jgloss/onthefly.html
 

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

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top