• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. SWT Toolbars > Adding Separators to Your Toolbar

4.5. Adding Separators to Your Toolbar

Separators enable you to group toolbar buttons into functional areas. If you look at the toolbar you created and executed in Figure 4-1, you will see that there are a couple of functional areas. The first is the Open and Save functionality. The second is the Cut, Copy, and Paste functionality. As it now appears, nothing distinguishes the two functional areas from each other as the user gazes at the toolbar. To provide that visual distinction, you must add a separator.

4.5.1. How do I do that?

Separators are easy to create:

final ToolItem separator = new ToolItem(bar, SWT.SEPARATOR);

If you insert this line of code in the location where you wish the separator to appear (between the code that creates the Save button and the code that creates the Cut button), the toolbar appears as in Figure 4-3—a distinct improvement.

Figure 4-3. Toolbar with separator


  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint