/* (non-Javadoc) * @see javax.microedition.lcdui.Displayable#handleShowEvent() */ void eswtHandleShowCurrentEvent() { // If it alert is first displayable, default // displayable should be shown behind alert if (topShell.isVisible() == false && nextDisplayable == null) { topShell.setVisible(true); } super.eswtHandleShowCurrentEvent(); topShell.addListener(SWT.Resize, resizeListener); // add key filter for scrollable text composite org.eclipse.swt.widgets.Display.getCurrent().addFilter(SWT.KeyDown, keyListener); org.eclipse.swt.widgets.Display.getCurrent().addFilter(SWT.Traverse, keyListener); org.eclipse.swt.widgets.Display.getCurrent().addFilter(SWT.MouseUp, keyListener); resetTimerTask(true); }
/** * Creates a new <code>Shell</code>. This Shell is the root for the SWT widgets that will be * embedded within the AWT canvas. * * @param display the display for the new Shell * @param parent the parent <code>java.awt.Canvas</code> of the new Shell * @return a <code>Shell</code> to be the parent of the embedded SWT widgets * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the display is null * <li>ERROR_NULL_ARGUMENT - if the parent is null * <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created * </ul> * * @since 3.0 */ public static Shell new_Shell(final Display display, final Canvas parent) { if (display == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (parent == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); int /*long*/ handle = 0; try { loadLibrary(); handle = getAWTHandle(parent); } catch (Throwable e) { SWT.error(SWT.ERROR_NOT_IMPLEMENTED, e); } if (handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT, null, " [peer not created]"); final Shell shell = Shell.cocoa_new(display, handle); final ComponentListener listener = new ComponentAdapter() { public void componentResized(ComponentEvent e) { display.asyncExec( new Runnable() { public void run() { if (shell.isDisposed()) return; Dimension dim = parent.getSize(); shell.setSize(dim.width, dim.height); } }); } }; parent.addComponentListener(listener); shell.addListener( SWT.Dispose, new Listener() { public void handleEvent(Event event) { parent.removeComponentListener(listener); } }); shell.setVisible(true); return shell; }