Using SWT Toolbars

The Browser project uses an SWT ToolBar widget to display a set of buttons, as you see in Figure 8.1. To create a toolbar in the SWT, you just connect the toolbar with the shell you're working with and set its style.

For example, take a look at the SWT ToolbarProject application, which appears in Figure 8.4. There are four buttons in the toolbar, and when the user clicks one, that button is identified in a message that appears in the Text widget.

Figure 8.4. Using a toolbar in an SWT application.

The ToolbarProject.java application creates a new Toolbar object this way (the SWT.NONE style indicates that the toolbar won't have ...

Get Java™ After Hours: 10 Projects You'll Never Do at Work now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.