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

Recipe 10.8 Adding Images to Tree Items

10.8.1 Problem

You want to add images to tree items.

10.8.2 Solution

Use the TreeItem class's setImage and getImage methods.

10.8.3 Discussion

To install an image for a tree item, pass the setImage method a new Image object. To see how to create Image objects, take a look at the Recipe 9.9 in Chapter 9. To get the image from a tree item, use the getImage method.

10.8.4 See Also

Recipe 9.9 on creating image menu items; Recipe 10.5 on creating trees in SWT; Recipe 10.6 on handling tree events; Recipe 10.7 on adding checkboxes to tree items.

    Previous Section  < Day Day Up >  Next Section