Uses a web browser to display : Browser HTML « SWT JFace Eclipse « Java






Uses a web browser to display

Uses a web browser to display

//Send questions, comments, bug reports, etc. to the authors:

//Rob Warner (rwarner@interspatial.com)
//Robert Harris (rbrt_harris@yahoo.com)

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
 * This class uses a web browser to display Slashdot's home page
 */
public class ShowSlashdot {
  /**
   * Runs the application
   */
  public void run() {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Slashdot");
    createContents(shell);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }

  /**
   * Creates the main window's contents
   * 
   * @param shell the main window
   */
  private void createContents(Shell shell) {
    shell.setLayout(new FillLayout());

    // Create a web browser
    Browser browser = new Browser(shell, SWT.NONE);

    // Navigate to Slashdot
    browser.setUrl("http://www.java2s.com");
  }

  /**
   * The application entry point
   * 
   * @param args the command line arguments
   */
  public static void main(String[] args) {
    new ShowSlashdot().run();
  }
}


           
       








Related examples in the same category

1.Modify HTML title tagModify HTML title tag
2.Query DOM node valueQuery DOM node value
3.HTML ExplorerHTML Explorer
4.Web Browser Composite
5.Another SWT Browser DemoAnother SWT Browser Demo
6.SWT Browser ExampleSWT Browser Example
7.SWT Browser
8.Implements a web browser 2Implements a web browser 2
9.Implements a web browserImplements a web browser
10.Render HTML that includes relative links from memoryRender HTML that includes relative links from memory
11.Bring up a browserBring up a browser
12.Another SWT BrowserAnother SWT Browser
13.HTML Explorer based on JFaceHTML Explorer based on JFace