diff options
author | Sven Gothel <[email protected]> | 2009-09-12 15:16:59 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-04-19 00:43:09 +0200 |
commit | 7cd1d4c59e8ffc7a4e0d83ad485ab46499e74d35 (patch) | |
tree | f083e79cb8048672c5b4ca2f45f8401783bec24e /src | |
parent | fe70cf568861e4addd8eb9a73f9832e7efaacaa5 (diff) |
NEWT: Native window parenting (X11: OK); AWTWindow external Frame OK
Diffstat (limited to 'src')
-rw-r--r-- | src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java index b13cf43..d86fbdc 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java @@ -66,10 +66,23 @@ public final class NWReflection { if (factoryClass == null) { throw new NativeWindowException(clazzName + " not available"); } + return getConstructor(factoryClass, cstrArgTypes); + } catch (Throwable e) { + if (DEBUG) { + e.printStackTrace(); + } + throw new NativeWindowException(e); + } + } + + public static final Constructor getConstructor(Class clazz, Class[] cstrArgTypes) { + Constructor factory = null; + + try { try { - factory = factoryClass.getDeclaredConstructor( cstrArgTypes ); + factory = clazz.getDeclaredConstructor( cstrArgTypes ); } catch(NoSuchMethodException nsme) { - throw new NativeWindowException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found"); + throw new NativeWindowException("Constructor: '" + clazz + "("+cstrArgTypes+")' not found"); } return factory; } catch (Throwable e) { @@ -84,6 +97,25 @@ public final class NWReflection { return getConstructor(clazzName, new Class[0]); } + public static final Object createInstance(Class clazz, Class[] cstrArgTypes, Object[] cstrArgs) { + Constructor factory = null; + + try { + factory = getConstructor(clazz, cstrArgTypes); + return factory.newInstance( cstrArgs ) ; + } catch (Exception e) { + throw new NativeWindowException(e); + } + } + + public static final Object createInstance(Class clazz, Object[] cstrArgs) { + Class[] cstrArgTypes = new Class[cstrArgs.length]; + for(int i=0; i<cstrArgs.length; i++) { + cstrArgTypes[i] = cstrArgs[i].getClass(); + } + return createInstance(clazz, cstrArgTypes, cstrArgs); + } + public static final Object createInstance(String clazzName, Class[] cstrArgTypes, Object[] cstrArgs) { Constructor factory = null; |