diff options
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java | 110 |
1 files changed, 35 insertions, 75 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java index 833a748240..ce86e7341c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java @@ -136,84 +136,44 @@ public static Frame new_Frame (final Composite parent) { if ((parent.getStyle () & SWT.EMBEDDED) == 0) { SWT.error (SWT.ERROR_INVALID_ARGUMENT); } - final int handle = parent.handle; - final Frame[] result = new Frame[1]; - final Throwable[] exception = new Throwable[1]; - Runnable runnable = new Runnable () { - public void run () { - try { - /* - * Some JREs have implemented the embedded frame constructor to take an integer - * and other JREs take a long. To handle this binary incompatability, use - * reflection to create the embedded frame. - */ - Class clazz = null; - try { - String className = embeddedFrameClass != null ? embeddedFrameClass : "sun.awt.windows.WEmbeddedFrame"; - clazz = Class.forName(className); - } catch (Throwable e) { - exception[0] = e; - return; - } - Constructor constructor = null; - try { - constructor = clazz.getConstructor (new Class [] {int.class}); - } catch (Throwable e1) { - try { - constructor = clazz.getConstructor (new Class [] {long.class}); - } catch (Throwable e2) { - exception[0] = e2; - return; - } - } - initializeSwing (); - Object value = null; - try { - value = constructor.newInstance (new Object [] {new Integer (handle)}); - } catch (Throwable e) { - exception[0] = e; - return; - } - final Frame frame = (Frame) value; - /* - * This is necessary to make lightweight components - * directly added to the frame receive mouse events - * properly. - */ - frame.addNotify(); - result[0] = frame; - } finally { - synchronized(result) { - result.notify(); - } - } - } - }; - if (EventQueue.isDispatchThread()) { - runnable.run(); - } else { - EventQueue.invokeLater(runnable); - boolean interrupted = false; - MSG msg = new MSG (); - int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_SENDMESSAGE; - while (result[0] == null && exception[0] == null) { - OS.PeekMessage (msg, 0, 0, 0, flags); - try { - synchronized (result) { - result.wait(50); - } - } catch (InterruptedException e) { - interrupted = true; - } - } - if (interrupted) { - Compatibility.interrupt(); + int handle = parent.handle; + /* + * Some JREs have implemented the embedded frame constructor to take an integer + * and other JREs take a long. To handle this binary incompatability, use + * reflection to create the embedded frame. + */ + Class clazz = null; + try { + String className = embeddedFrameClass != null ? embeddedFrameClass : "sun.awt.windows.WEmbeddedFrame"; + clazz = Class.forName(className); + } catch (Throwable e) { + SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e); + } + Constructor constructor = null; + try { + constructor = clazz.getConstructor (new Class [] {int.class}); + } catch (Throwable e1) { + try { + constructor = clazz.getConstructor (new Class [] {long.class}); + } catch (Throwable e2) { + SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e2); } } - if (exception[0] != null) { - SWT.error (SWT.ERROR_NOT_IMPLEMENTED, exception[0]); + initializeSwing (); + Object value = null; + try { + value = constructor.newInstance (new Object [] {new Integer (handle)}); + } catch (Throwable e) { + SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e); } - final Frame frame = result[0]; + final Frame frame = (Frame) value; + /* + * This is necessary to make lightweight components + * directly added to the frame receive mouse events + * properly. + */ + frame.addNotify(); + parent.setData(EMBEDDED_FRAME_KEY, frame); /* Forward the iconify and deiconify events */ |