Add multiple items to a Tree

How can I add two items with the same text to a tree? Currently when I do this it just ignores the duplicates. Code example (in Clojure ) shown:

[font=Courier New]
(let [
t (Tree.)
]

(. t addItem “a”)
(. t addItem “b”)
(. t addItem “a”)

t
)

[/font]

Only one “a” and one “b” is shown

Remember that the parameter for the addItem() is an
item identifier
, not the item itself, which is created internally by the container. However, in the default caption mode, the item IDs are used also for item captions, so if the IDs are strings (or provide toString()), there doesn’t appear to be any difference between adding items and item IDs.

You can set the item caption explicitly with setItemCaption(). In such case, the item ID can be anything, such as automatically generated by addItem().

So, you can add items with (in Java):

Object itemId1 = tree.addItem();
tree.setItemCaption(itemId1, "a");

brilliant, that worked. Thanks!