0 Replies - 6003 Views - Last Post: 28 March 2012 - 11:59 AM

#1 Sinned  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 208
  • Joined: 13-October 10

[JNI] Low level event handling

Posted 28 March 2012 - 11:59 AM

Hello everyone,

Maybe this is a bit unusual question, and I don't think this is been done very much before, so I hope someone here knows something about it.

I should like to let the events from java get handled by the OS - for now I test it on Microsoft Windows 7.
Normally java runs on the OS, and the OS gives all handles/events through to the JVM (which is running your code).
Now I want to take back these handles to the OS on a low level (without java forwarding).

For example:
I want to handle java window resize native by the OS.

This is should be the java class (which is an applet):
public class loader extends java.applet.Applet
		Runtime.getRuntime().loadLibrary("mySharedObject"); //loads mySharedObject.dll
	public native void init();

In this case "init" is native, so this is getting called in the "mySharedObject.dll" file.

The loader.cpp file has to look like:
#include "loader.h"
#include <jni.h>

JNIEXPORT void JNICALL Java_loader_init(JNIEnv *env, jobject o)
	//here do something native like addResizeListener

loader.h isn't a very special jni header, so I won't show it here.

I hope you have a good image of the plan.

On the internet there isn't much findable about this, so I came here.

My help requirements:
I hope someone could tell me more about how the OS (Windows 7) forwards the pulses/events to Java, so I can intercept them (native) and make them my own.



Is This A Good Question/Topic? 0
  • +

Page 1 of 1