public TreeBean() {
// create root node with its children expanded
DefaultMutableTreeNode rootTreeNode = new DefaultMutableTreeNode();
IceUserObject rootObject = new IceUserObject(rootTreeNode);
rootObject.setText("Root Node");
rootObject.setExpanded(true);
rootObject.setBranchContractedIcon(XP_BRANCH_CONTRACTED_ICON);
rootObject.setBranchExpandedIcon(XP_BRANCH_EXPANDED_ICON);
rootObject.setLeafIcon(XP_BRANCH_LEAF_ICON);
rootTreeNode.setUserObject(rootObject);
// model is accessed by by the ice:tree component
model = new DefaultTreeModel(rootTreeNode);
// add some child notes
for (int i = 0; i < 3; i++) {
DefaultMutableTreeNode branchNode = new DefaultMutableTreeNode();
IceUserObject branchObject = new IceUserObject(branchNode);
branchObject.setText("node-" + i);
branchObject.setBranchContractedIcon(XP_BRANCH_CONTRACTED_ICON);
branchObject.setBranchExpandedIcon(XP_BRANCH_EXPANDED_ICON);
branchObject.setLeafIcon(XP_BRANCH_LEAF_ICON);
branchObject.setLeaf(true);
branchNode.setUserObject(branchObject);
rootTreeNode.add(branchNode);
// add some more sub children
for (int k = 0; k < 2; k++) {
DefaultMutableTreeNode subBranchNode = new DefaultMutableTreeNode();
IceUserObject subBranchObject = new IceUserObject(subBranchNode);
subBranchObject.setText("sub-node-" + i + "-" + k);
subBranchObject.setBranchContractedIcon(XP_BRANCH_CONTRACTED_ICON);
subBranchObject.setBranchExpandedIcon(XP_BRANCH_EXPANDED_ICON);
subBranchObject.setLeafIcon(XP_BRANCH_LEAF_ICON);
branchObject.setLeaf(true);
subBranchNode.setUserObject(subBranchObject);
branchNode.add(subBranchNode);
}
}