Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.swt.browser
Class WindowEvent

java.lang.Object
  extended byjava.util.EventObject
      extended byorg.eclipse.swt.internal.SWTEventObject
          extended byorg.eclipse.swt.events.TypedEvent
              extended byorg.eclipse.swt.browser.WindowEvent

All Implemented Interfaces:
Serializable


public class WindowEvent
extends TypedEvent

A WindowEvent is sent by a Browser when a new window needs to be created or when an existing window needs to be closed. This notification occurs when a javascript command such as window.open or window.close gets executed by a Browser.

The following example shows how WindowEvent's are typically handled.

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("Main Window");
        shell.setLayout(new FillLayout());
        Browser browser = new Browser(shell, SWT.NONE);
        initialize(display, browser);
        shell.open();
        browser.setUrl("http://www.eclipse.org");
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }

    static void initialize(final Display display, Browser browser) {
        browser.addOpenWindowListener(new OpenWindowListener() {
            public void open(WindowEvent event) {
                Shell shell = new Shell(display);
                shell.setText("New Window");
                shell.setLayout(new FillLayout());
                Browser browser = new Browser(shell, SWT.NONE);
                initialize(display, browser);
                event.browser = browser;
            }
        });
        browser.addVisibilityWindowListener(new VisibilityWindowListener() {
            public void hide(WindowEvent event) {
                Browser browser = (Browser)event.widget;
                Shell shell = browser.getShell();
                shell.setVisible(false);
            }
            public void show(WindowEvent event) {
                Browser browser = (Browser)event.widget;
                Shell shell = browser.getShell();
                if (event.location != null) shell.setLocation(event.location);
                if (event.size != null) {
                    Point size = event.size;
                    shell.setSize(shell.computeSize(size.x, size.y));
                }
                shell.open();
            }
        });
        browser.addCloseWindowListener(new CloseWindowListener() {
            public void close(WindowEvent event) {
                Browser browser = (Browser)event.widget;
                Shell shell = browser.getShell();
                shell.close();
            }
        });
    }
 

Since:
3.0
See Also:
CloseWindowListener, OpenWindowListener, VisibilityWindowListener, Serialized Form


Field Summary
 Browser browser
          Browser provided by the application.
 Point location
          Requested location for the Shell hosting the Browser.
 Point size
          Requested client size for the Shell hosting the Browser.
 
Fields inherited from class org.eclipse.swt.events.TypedEvent
data, display, time, widget
 
Fields inherited from class java.util.EventObject
source
 
Methods inherited from class org.eclipse.swt.events.TypedEvent
toString
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

 

Field Detail

 

 

browser

public Browser browser

Browser provided by the application. Default is null and null will cancel the associated navigation request.


 

 

location

public Point location

Requested location for the Shell hosting the Browser. It is null if no location has been requested.


 

 

size

public Point size

Requested client size for the Shell hosting the Browser. It is null if no size has been requested.


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.