Issue with tree component

I am experimenting with Vaadin. I wrote following code which does not work as expected.

The child elements show up as siblings of intended parent.
Any ideas?

    Object itemId, itemIdParent;
    Tree tree_1 = new Tree();
    tree_1.setCaption("Actions");

    itemIdParent = tree_1.addItem("00");
    tree_1.setItemCaption(itemIdParent, "Manage Database");

    itemId = tree_1.addItem("aa");
    tree_1.setParent(itemId, itemIdParent);
    tree_1.setItemCaption(itemId, "New database object");
    tree_1.setChildrenAllowed(itemId, false);
    itemId = tree_1.addItem("bb");
    tree_1.setParent(itemId, itemIdParent);
    tree_1.setItemCaption(itemId, "Existing database objects");
    tree_1.setChildrenAllowed(itemId, false);

    tree_1.addListener(new ItemClickEvent.ItemClickListener() {
        public void itemClick(ItemClickEvent event) {
            // Pick only left mouse clicks
            if (event.getButton() == ItemClickEvent.BUTTON_LEFT) {
                System.err.println(event.getItemId());
                switch((String) event.getItemId()) {
                    case "aa":
                        System.err.println("a");
                        break;
                    case "bb":
                        System.err.println("e");
                        break;
                    default:
                        System.err.println("action for tree item \"" + event.getItemId() + "\" is not defined");
                        break;
                }
            }
                
        }
    });

Hello Vinay,

You have to use itemID instead of item, when ever you do addItem() you are actually creating a new item! So to get an hierarchy modify your code like shown below. tree_1.setParent("aa", "00"); instead of [s] tree_1.setParent(itemId, itemIdParent); [/s] it would work like a charm.
Hope this solves your problem. If any issues please let me know

Thanks,
Krishna