Another SWT Browser : Browser HTML « SWT JFace Eclipse « Java

Another SWT Browser

Another SWT Browser

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class BrowserClass {
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Browser Example");
    shell.setSize(620, 500);

    ToolBar toolbar = new ToolBar(shell, SWT.NONE);
    toolbar.setBounds(5, 5, 200, 30);

    ToolItem goButton = new ToolItem(toolbar, SWT.PUSH);

    ToolItem backButton = new ToolItem(toolbar, SWT.PUSH);

    ToolItem stopButton = new ToolItem(toolbar, SWT.PUSH);

    final Text text = new Text(shell, SWT.BORDER);
    text.setBounds(5, 35, 400, 25);

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

    Listener listener = new Listener() {
      public void handleEvent(Event event) {
        ToolItem item = (ToolItem) event.widget;
        String string = item.getText();
        if (string.equals("Back"))
        else if (string.equals("Stop"))
        else if (string.equals("Go"))

    goButton.addListener(SWT.Selection, listener);
    backButton.addListener(SWT.Selection, listener);
    stopButton.addListener(SWT.Selection, listener);

    text.addListener(SWT.DefaultSelection, new Listener() {
      public void handleEvent(Event e) {
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())


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.Uses a web browser to displayUses a web browser to display
11.Render HTML that includes relative links from memoryRender HTML that includes relative links from memory
12.Bring up a browserBring up a browser
13.HTML Explorer based on JFaceHTML Explorer based on JFace