diff options
author | Sven Gothel <[email protected]> | 2009-09-12 15:16:59 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-09-12 15:16:59 -0700 |
commit | 4fe426caf55889d17b387efa06551c1af8f0dabe (patch) | |
tree | ccd41a542053de870339485b902d180d4029ebb0 /src/nativewindow | |
parent | 3cc7335e94df9daaab5250487b9f03e19aaa292a (diff) |
NEWT: Native window parenting (X11: OK); AWTWindow external Frame OK
Diffstat (limited to 'src/nativewindow')
-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 b13cf4317..d86fbdc55 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; |