< Day Day Up > |
Recipe 10.2 Creating SWT Coolbars10.2.1 ProblemYou want to wow users with coolbars, which feature sliding, resizeable toolbars. 10.2.2 SolutionCreate a coolbar and add the toolbars you want the user to slide around as cool items in the coolbar. Use the cool items' setControl method to add the toolbars to each cool item. 10.2.3 DiscussionIn this example, CoolBarApp in the code for this book, we'll put together a coolbar with two sliding toolbars. Here's a selection of the most useful CoolBar methods:
Creating the coolbar in this example is easy; just use the CoolBar constructor and set the layout you want to use: public class CoolBarClass { static Display display; static Shell shell; static CoolBar coolBar; public static void main(String[] args) { display = new Display( ); shell = new Shell(display); shell.setLayout(new GridLayout( )); shell.setText("CoolBar Example"); shell.setSize(600, 200); coolBar = new CoolBar(shell, SWT.BORDER | SWT.FLAT); coolBar.setLayoutData(new GridData(GridData.FILL_BOTH)); . . . The next step is to add coolbar items containing toolbars, which we'll cover in the next recipe. 10.2.4 See AlsoRecipe 10.3 on adding items to coolbars; Recipe 10.4 on adding drop-down menus to coolbars. |
< Day Day Up > |