Recipe 9.9 Creating Image Menu Items


9.9.1 Problem

You want to display images in menu items.

9.9.2 Solution

Use the MenuItem class's setImage method.

9.9.3 Discussion

You can pass an Image object to a MenuItem object's setImage method to add an image to a menu item. Here's an example:

 Display display = new Display ( ); final Image image = new Image (display, "c:\helpitem.jpg");         .         .         . menuItem.setImage(image); 

9.9.4 See Also

Recipe 9.7 on creating a menu system; Recipe 9.8 on creating text menu items; Recipe 9.10 on creating radio menu items; Recipe 9.11 on creating menu item accelerators and mnemonics ; Recipe 9.12 on enabling and disabling menu items; Chapter 8 in Eclipse (O'Reilly).

Eclipse Cookbook
Inside XML (Inside (New Riders))
ISBN: 596007108
EAN: 2147483647
Year: 2006
Pages: 232
Authors: Steve Holzner

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: