Basically what you need is just an structure that will hold a few children and you model properties. You could represent this with a class structure like this:
public class TreeNode {
private Collection<TreeNode> children;
private String caption;
public TreeNode(Collection<TreeNode> children, String caption) {
super();
this.children = children;
this.caption = caption;
}
public Collection<TreeNode> getChildren() {
return children;
}
public void setChildren(Collection<TreeNode> children) {
this.children = children;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
}
You could take a look here, in order to take some ideas: Java tree data-structure?