📄 firsttree2.html
字号:
<html jwcid="@Shell" title="Using The Tapestry Tree Control" stylesheet="ognl:assets.stylesheet"><head jwcid="@Block"> <link rel="stylesheet" type="text/css" href="../css/style.css"/></head><body jwcid="@Body"> <h1>Creating a populated ITreeModel</h1> <div class="note"> This page demonstrates how to create a populated ITreeModel using SimpleTreeDataModel and SimpleTreeModel with our custom StringTreeNode. </div> <table border="1"> <tr> <td valign="top"> <span class="tree" jwcid="treeView"> <span jwcid="treeDataView"> <span jwcid="treeNodeView"/> </span> </span> </td> </tr> </table> <p> The distribution includes the classes SimpleTreeDataModel and SimpleTreeModel that can be used to wrap our custom StringTreeNode objects. Here is a code snippet from <code>FirstTreePage.java</code> that demonstrates how you can use these classes:<div class="code"><pre> public ITreeModel getTreeModel() { if (treeModel == null) { System.out.println("creating SimpleTreeModel"); // Create and "connect" all the nodes TreeNode node1 = new StringTreeNode("Root Node"); TreeNode node2 = new StringTreeNode("Child One"); TreeNode node2a = new StringTreeNode("Grandchild One"); node2.insert(node2a); node1.insert(node2); TreeNode node3 = new StringTreeNode("Child Two"); TreeNode node3a = new StringTreeNode("GrandChild Two"); node3.insert(node3a); TreeNode node3a1 = new StringTreeNode("Great Grandchild One"); node3a.insert(node3a1); node1.insert(node3); // Wrap the root node in a SimpleTreeDataModel treeDataModel = new SimpleTreeDataModel(node1); // Wrap the SimpleTreeDataModel in a SimpleTreeModel treeModel = new SimpleTreeModel(treeDataModel); } return treeModel; }</pre></div><p> That's about all you have to do to create a simple tree that renders Strings. Most likely you will want to perform some action when the user clicks on a node. We'll do that next.<p><a href="#" jwcid="@PageLink" page="FirstTree3">Performing an action when a node is clicked...</a><p> <a href="#" jwcid="@PageLink" page="Home">Return to Home Page...</a></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -