JNI and event listeners in native code? - Java

This is a discussion on JNI and event listeners in native code? - Java ; 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 ...

+ Reply to Thread
Results 1 to 2 of 2

JNI and event listeners in native code?

  1. Default JNI and event listeners in native code?

    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



  2. Default Re: JNI and event listeners in native code?

    On Tue, 28 Oct 2008 13:41:04 +0100, "Martijn Tonies"
    <m.tonies@upscene.removethis.com> wrote, quoted or indirectly quoted
    someone who said :

    >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
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    A vote for McCain is fearful clinging to McSame.
    A vote for Obama is a shot at Obamalot.

+ Reply to Thread