HTMLTreeElement class

The HTMLTreeElement class represents an hierarchical element within an HTMLTree or other HTMLTreeElements.

Many tree element attributes can be retrieved or updating using methods that are provided in the HTMLTreeElement class. Some of the actions you can do with these methods are:

The following example creates an HTMLTreeElement object and displays the tag:

       // Create an HTMLTree.
       HTMLTree tree = new HTMLTree();

       // Create parent HTMLTreeElement.
       HTMLTreeElement parentElement = new HTMLTreeElement();
       parentElement.setTextUrl(new HTMLHyperlink("http://myWebPage", "My Web Page"));
       

       // Create HTMLTreeElement Child.
       HTMLTreeElement childElement = new HTMLTreeElement();
       childElement.setTextUrl(new HTMLHyperlink("http://anotherWebPage", "Another Web Page"));
       parentElement.addElement(childElement);

       // Add the tree element to the tree.
       tree.addElement(parentElement);
       System.out.println(tree.getTag());

The getTag() method in the above example generates HTML tags like the following:

<table cellpadding="0" cellspacing="3">
<tr>
<td><font color="#0000FF"><u>-</u></font> </td>
<td><font color="#0000FF"><u>My Web Page</u></font></td>
</tr>

<tr>
<td> </td>
<td>
<table cellpadding="0" cellspacing="3">
<tr>
<td><font color="#0000FF"><u>-</u></font> </td>
<td><font color="#0000FF"><u>Another Web Page</u></font> </td>
</tr>
</table>
</td>
</tr>
</table>