Java tutorial
import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class MainClass { public static void main(String[] a) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setSize(250, 200); shell.setLayout(new FormLayout()); Composite controls = new Composite(shell, SWT.NONE); FormData data = new FormData(); data.top = new FormAttachment(0, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); controls.setLayoutData(data); final Browser browser = new Browser(shell, SWT.NONE); data = new FormData(); data.top = new FormAttachment(controls); data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); browser.setLayoutData(data); controls.setLayout(new GridLayout(6, false)); Button button = new Button(controls, SWT.PUSH); button.setText("Back"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.back(); } }); button = new Button(controls, SWT.PUSH); button.setText("Forward"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.forward(); } }); button = new Button(controls, SWT.PUSH); button.setText("Refresh"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.refresh(); } }); button = new Button(controls, SWT.PUSH); button.setText("Stop"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.stop(); } }); final Text url = new Text(controls, SWT.BORDER); url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); url.setFocus(); button = new Button(controls, SWT.PUSH); button.setText("Go"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.setUrl(url.getText()); } }); shell.setDefaultButton(button); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }