O'Reilly logo

Java™ After Hours: 10 Projects You'll Never Do at Work by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Browser Project

As shown earlier in Figure 8.1, the Browser project uses ToolBar, Text, and Browser widgets. It starts by creating a good-sized shell to display the browser in:

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class BrowserProject
{
    Display display;
					Shell shell;

    public static void main(String[] args)
    {
        new BrowserProject();
    }

    BrowserProject()
    {
        display = new Display();
					shell = new Shell(display);
					shell.setText("The Browser Project");
					shell.setSize(600, 500);
        .
        .
        .
}

Then it creates the toolbar and buttons you see in Figure 8.1:

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class BrowserProject
{
    Display display;
    Shell shell;
    ToolBar toolbar;
					ToolItem go, forward, back, refresh, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required