DekGenius.com
Previous Section  < Day Day Up >  Next Section

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).

    Previous Section  < Day Day Up >  Next Section