[no subject]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]<

 



If you don't know how to build jni's, have a look on the net. I actually 
generate my ExtendedCanvas.dll (for Windows) on Linux, with the mingw 
crosscompiler :-)
You have to add the compiled libExtendedCanvas.so or ExtendedCanvas.dll to 
your classpath, so that java can find them, with System.loadlibrary

Good luck

Bart


-----------------------------------------------------------------------------------------------------------------------------
ExtendedCanvas.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class avialogic_jmplayer_ExtendedCanvas */

#ifndef _Included_avialogic_jmplayer_ExtendedCanvas
#define _Included_avialogic_jmplayer_ExtendedCanvas
#ifdef __cplusplus
extern "C" {
#endif

#undef avialogic_jmplayer_ExtendedCanvas_FOCUS_TRAVERSABLE_UNKNOWN
#define avialogic_jmplayer_ExtendedCanvas_FOCUS_TRAVERSABLE_UNKNOWN 0L
#undef avialogic_jmplayer_ExtendedCanvas_FOCUS_TRAVERSABLE_DEFAULT
#define avialogic_jmplayer_ExtendedCanvas_FOCUS_TRAVERSABLE_DEFAULT 1L
#undef avialogic_jmplayer_ExtendedCanvas_FOCUS_TRAVERSABLE_SET
#define avialogic_jmplayer_ExtendedCanvas_FOCUS_TRAVERSABLE_SET 2L
#undef avialogic_jmplayer_ExtendedCanvas_TOP_ALIGNMENT
#define avialogic_jmplayer_ExtendedCanvas_TOP_ALIGNMENT 0.0f
#undef avialogic_jmplayer_ExtendedCanvas_CENTER_ALIGNMENT
#define avialogic_jmplayer_ExtendedCanvas_CENTER_ALIGNMENT 0.5f
#undef avialogic_jmplayer_ExtendedCanvas_BOTTOM_ALIGNMENT
#define avialogic_jmplayer_ExtendedCanvas_BOTTOM_ALIGNMENT 1.0f
#undef avialogic_jmplayer_ExtendedCanvas_LEFT_ALIGNMENT
#define avialogic_jmplayer_ExtendedCanvas_LEFT_ALIGNMENT 0.0f
#undef avialogic_jmplayer_ExtendedCanvas_RIGHT_ALIGNMENT
#define avialogic_jmplayer_ExtendedCanvas_RIGHT_ALIGNMENT 1.0f
#undef avialogic_jmplayer_ExtendedCanvas_serialVersionUID
#define 
avialogic_jmplayer_ExtendedCanvas_serialVersionUID -7644114512714619750LL
#undef avialogic_jmplayer_ExtendedCanvas_serialVersionUID
#define 
avialogic_jmplayer_ExtendedCanvas_serialVersionUID -2284879212465893870LL
/*
 * Class:     avialogic_jmplayer_ExtendedCanvas
 * Method:    getNativeWindow
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_avialogic_jmplayer_ExtendedCanvas_getNativeWindow
  (JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

-----------------------------------------------------------------------------------------------------------------------------
ExtendedCanvas.c

#include <jni.h>
#include <jawt.h>
#include <jawt_md.h>
#include <assert.h>
#ifdef WIN32
#include <windows.h>
#endif

#include "ExtendedCanvas.h"


JNIEXPORT jint JNICALL Java_avialogic_jmplayer_ExtendedCanvas_getNativeWindow
  (JNIEnv *env, jobject obj_this)
{
jboolean result;
	jint lock;

	JAWT awt;
	JAWT_DrawingSurface* ds;
	JAWT_DrawingSurfaceInfo* dsi;
#ifdef WIN32
	JAWT_Win32DrawingSurfaceInfo* dsi_win;
	HWND hWnd;
#else
	JAWT_X11DrawingSurfaceInfo* dsi_x11;
#endif

	/* Get the AWT */
	awt.version = JAWT_VERSION_1_3;
	result = JAWT_GetAWT(env, &awt);
	if(result == JNI_FALSE) return -1;

								/* Get the drawing surface */
	if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
		return 0L;

	/* Lock the drawing surface */
	lock = ds->Lock(ds);
	if((lock & JAWT_LOCK_ERROR)  ) {
		return -1;
	}

	/* Get the drawing surface info */
	dsi = ds->GetDrawingSurfaceInfo(ds);

	/* Get the platform-specific drawing info */
#ifdef WIN32
	dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
	//hdc= dsi_win->hdc;
	hWnd = dsi_win->hwnd;
	return ((jlong)hWnd);
#else
	dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
	int id = dsi_x11->drawable;

	ds->Unlock(ds);
	return id;
#endif


}


-----------------------------------------------------------------------------------------------------------------------------
ExtendedCanvas.java

package avialogic.jmplayer;


/** awt.canvas with access method forwindow id.
 * 
 * @author bvandeenen
 *
 * uses JNI file for getting to window id 
 */
public class ExtendedCanvas extends java.awt.Canvas
{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /** gets native window id.
     * 
     * @return native window id
     */
    public native int getNativeWindow();

    static
    {
        // if this fails make sure you read 
        try
        {
            Util.loadLibrary("ExtendedCanvas");
            Util.loadLibrary("jawt");
        }
        catch (Throwable e)
        {
            e.printStackTrace();
            System.exit(1);
        }

    }

}


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux