9.9. Creating Image Menu Items
Problem
You want to display images in menu items.
Solution
Use the MenuItem
class’s
setImage
method.
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);
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).
Get Eclipse Cookbook 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.