Java Reference
In-Depth Information
AdvancedUseofeSWT
To demonstrate a highly powerful feature of eSWT, we use
org.ecli-
pse.swt.browser.Browser
embedded into an application (see
Figure 3.7).
Figure 3.7
eSWT browser
In the following example code, the user can set a URL and navigate
back and forth between visited web pages. (Using
MIDlet.plat-
formRequest()
does not allow you to programmatically navigate
between different pages; the eSWT Browser API does let you do it.)
import org.eclipse.swt.browser.Browser;
public class BrowserMIDlet extends MIDlet implements SelectionListener,
Runnable
{
...
// UI Thread run() method
public void run()
{
...
browser = new Browser(shell, SWT.NONE);
browser.setUrl("http://forumnokia.mobi");
shell.open();
while (!exiting)
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
browser.dispose();
shell.dispose();
display.dispose();
notifyDestroyed();
}