The important code:
Browser browser = new Browser(shell, SWT.NONE);
URL url = this.getClass().getResource("/example.html");
browser.setUrl(url.toString());
shell.open();
P.S. I've carefully considered what Masijade and others told me in the other thread; the example.html file is located in multiple locations, including in the same directory as the .class file. . I also tried url.getFile(), and I also tried "example.html", among a lot of other attempts, none worked. I got the html page to display once or twice with getResource(), and it always works if I specify the exact path, but I cannot do that in the real product. If anyone sees any errors please let me know. I also looked at the example on the swt website at eclipse.org, but their example forces the user to specify the pathname (by browsing their machine) so it is fundamentally different than mine.
The full code:
final Shell shell = new Shell(display);
shell.setText("Basic Tutorial");
shell.setLayout(new GridLayout());
shell.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Browser browser = new Browser(shell, SWT.NONE);
browser.setLayout(new GridLayout());
browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
URL url = this.getClass().getResource("/example.html");
browser.setUrl(url.toString());
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
shell.dispose();