Example usage for org.eclipse.swt.browser Browser setBounds

List of usage examples for org.eclipse.swt.browser Browser setBounds

Introduction

In this page you can find the example usage for org.eclipse.swt.browser Browser setBounds.

Prototype

public void setBounds(int x, int y, int width, int height) 

Source Link

Document

Sets the receiver's size and location to the rectangular area specified by the arguments.

Usage

From source file:BrowserLoadingWebsite.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(5, 5, 600, 600);

    browser.setUrl("http://java2s.com");
    shell.open();/*w w w .j  av  a 2  s .  c om*/

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:BrowserCloseWindowListener.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(5, 5, 600, 600);

    browser.addCloseWindowListener(new CloseWindowListener() {
        public void close(WindowEvent event) {
            System.out.println("closing");
            Browser browser = (Browser) event.widget;
            Shell shell = browser.getShell();
            shell.close();//w ww. j  a va 2  s. c  o m
        }
    });

    browser.setUrl("http://java2s.com");
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:BrowserLocationListener.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(5, 5, 600, 600);

    browser.addLocationListener(new LocationListener() {
        public void changed(LocationEvent event) {
            if (event.top)
                System.out.println(event.location);
        }//from  w  w w . j  av a 2  s .co m

        public void changing(LocationEvent event) {
        }
    });

    browser.setUrl("http://java2s.com");
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:OpenWindowListenerUsing.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(5, 5, 600, 600);

    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);
            event.browser = browser;/*w w w  .j av  a  2s . co m*/
        }
    });

    browser.setUrl("http://java2s.com");
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:BrowserProgress.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(5, 5, 600, 600);

    final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE);
    progressBar.setBounds(5, 650, 600, 20);

    browser.addProgressListener(new ProgressListener() {
        public void changed(ProgressEvent event) {
            if (event.total == 0)
                return;
            int ratio = event.current * 100 / event.total;
            progressBar.setSelection(ratio);
        }//  w  w w .  ja  v  a 2s  .  co m

        public void completed(ProgressEvent event) {
            progressBar.setSelection(0);
        }
    });

    browser.setUrl("http://java2s.com");
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:VisibilityWindowListenerUsing.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(5, 5, 600, 600);

    browser.addVisibilityWindowListener(new VisibilityWindowListener() {
        public void hide(WindowEvent event) {
            System.out.println("hide");
            Browser browser = (Browser) event.widget;
            Shell shell = browser.getShell();
            shell.setVisible(false);//  w  ww .j  ava 2  s .c  o  m
        }

        public void show(WindowEvent event) {
            Browser browser = (Browser) event.widget;
            final Shell shell = browser.getShell();
            System.out.println("Popup blocked.");
            shell.open();
        }
    });

    browser.setUrl("http://java2s.com");
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}