Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / Windows Forms

Hosting WPF Content in a Java Application

Rate me:
Please Sign up or sign in to vote.
4.94/5 (8 votes)
26 Apr 2009CPOL4 min read 73K   3.1K   28  
Demonstrates a simple technique for embedding WPF/.NET Components into Java GUI
namespace ObjectOrientedJNIInterop.com.oojni {
    
    public class CalendarContainer : ObjectOrientedJNI.JObject {
        public static ObjectOrientedJNI.JClass clazz = null;
        static CalendarContainer() {
            clazz = ObjectOrientedJNI.JNIEnvHelper.FindClass("com/oojni/CalendarContainer");
        }
        public CalendarContainer() {
        }
        public CalendarContainer(ObjectOrientedJNI.JObject o) : 
                base(o) {
        }
    }
    public abstract class CalendarContainerJNIProxy : CalendarContainer {
        public CalendarContainerJNIProxy(ObjectOrientedJNI.JObject o) : 
                base(o) {
        }
        public abstract int getYearFromControl(int p0);
        public abstract int getMonthFromControl(int p0);
        public abstract int getDayFromControl(int p0);
        public abstract void setSystemTime(int p0, int p1, int p2, int p3, int p4, int p5, int p6);
        public abstract int create(ObjectOrientedJNI.JObject p0);
        public abstract void dispose(int p0);
    }
}
namespace ObjectOrientedJNIInterop.com.oojni {
    using System;
    using ObjectOrientedJNI;
    using ObjectOrientedJNI.PrimitiveArrays;
    
    public class CalendarContainerJNINatives {
        public static int Java_com_oojni_CalendarContainer_getYearFromControl(int env, int obj, int p0) {
            try {
                return new CalendarContainerJNINImpl(new ObjectOrientedJNI.JObject(obj)).getYearFromControl(p0);
            }
            catch (System.Exception e) {
                ObjectOrientedJNI.JNIEnvHelper.ThrowNew("Exception in Native Code");
                return 0;
            }
        }
        public static int Java_com_oojni_CalendarContainer_getMonthFromControl(int env, int obj, int p0) {
            try {
                return new CalendarContainerJNINImpl(new ObjectOrientedJNI.JObject(obj)).getMonthFromControl(p0);
            }
            catch (System.Exception e) {
                ObjectOrientedJNI.JNIEnvHelper.ThrowNew("Exception in Native Code");
                return 0;
            }
        }
        public static int Java_com_oojni_CalendarContainer_getDayFromControl(int env, int obj, int p0) {
            try {
                return new CalendarContainerJNINImpl(new ObjectOrientedJNI.JObject(obj)).getDayFromControl(p0);
            }
            catch (System.Exception e) {
                ObjectOrientedJNI.JNIEnvHelper.ThrowNew("Exception in Native Code");
                return 0;
            }
        }
        public static void Java_com_oojni_CalendarContainer_setSystemTime(int env, int obj, int p0, int p1, int p2, int p3, int p4, int p5, int p6) {
            try {
                new CalendarContainerJNINImpl(new ObjectOrientedJNI.JObject(obj)).setSystemTime(p0, p1, p2, p3, p4, p5, p6);
            }
            catch (System.Exception e) {
                ObjectOrientedJNI.JNIEnvHelper.ThrowNew("Exception in Native Code");
            }
        }
        public static int Java_com_oojni_CalendarContainer_create(int env, int obj, int p0) {
            try {
                return new CalendarContainerJNINImpl(new ObjectOrientedJNI.JObject(obj)).create(new ObjectOrientedJNI.JObject(p0));
            }
            catch (System.Exception e) {
                ObjectOrientedJNI.JNIEnvHelper.ThrowNew("Exception in Native Code");
                return 0;
            }
        }
        public static void Java_com_oojni_CalendarContainer_dispose(int env, int obj, int p0) {
            try {
                new CalendarContainerJNINImpl(new ObjectOrientedJNI.JObject(obj)).dispose(p0);
            }
            catch (System.Exception e) {
                ObjectOrientedJNI.JNIEnvHelper.ThrowNew("Exception in Native Code");
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Javain Ltd
Israel Israel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions