Tree description

zhaozj2021-02-16  52

The tree is composed of nodes, in Java, uses the DefaultMutableTreenode class to create nodes. The process of creation is simple. First create a root node, then create a child of the root node, let the child node add your child node to the parent node after adding the Add (MutableTreenodenewChild) method.

// Create a node DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode ( "Java"); DefaultMutableTreeNode books = new DefaultMutableTreeNode ( "Java books"); DefaultMutableTreeNode tools = new DefaultMutableTreeNode ( "Java Development Tools");

// Add a child node rootnode.add (booS); rootnode.add (tools);

Books.Add (New DefaultMutableTreenode); Books.Add (New DefaultMutableTreenode ("Java Programming Thought")); Books.Add (New DefaultmutableTreenode ("Java Programming Detailed");

Tools.Add (New DefaultmutableTreenode ("jbuilder"); Tools.Add (New DefaultmutableTreenode ("jcreat")); Tools.Add (New DefaultmutableTreenode); "Visual J ));

转载请注明原文地址:https://www.9cbs.com/read-20069.html

New Post(0)