// Create a TreeViewNode object
// Set the properties of the new TreeViewNode
TreeViewNode treeView = diagram.getFactory().createTreeViewNode(10, 10, 50, 50);
treeView.setFont(new Font("Times New Roman", Font.BOLD,5));
treeView.setCaption("Tree view");
treeView.setCaptionHeight(5);
// Add root items
for (int i = 0; i < 5; i++)
{
// Create a TreeViewItem object
TreeViewItem rootItem = new TreeViewItem("Root " + i);
rootItem.setLabelFont(new Font("Verdana", Font.ITALIC, 4));
// The root item is added to the tree view
treeView.getRootItems().add(rootItem);
// Add two children items to the root item
for (int j = 0; j < 2; j++)
{
TreeViewItem item = new TreeViewItem();
item.setLabel("Child " + j);
item.setLabelFont(new Font("Verdana", Font.PLAIN, 3));
// Add the child item to the root item
rootItem.getChildren().add(item);
}
}