10.8. Adding Images to Tree Items
Problem
You want to add images to tree items.
Solution
Use the TreeItem
class’s
setImage
and getImage
methods.
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.
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.
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.