A specific node in the tree can be identified by TreePath (the object that encapsulates the node and all its ancestors) or by its display row, where each row in the display area displays a node. The expansion node is a non-leaf node (identified by a return of false TreeModel.isLeaf(node) ), and when all its ancestors are expanded , the node displays its child nodes. collapsing nodes are the nodes that hide them. A hidden node is a node that is located below the collapsed ancestor. The parent no
Weblogic and IBM Websphere. Therefore, when designing a software configuration file, we will increasingly consider using XML as the format of the configuration file.
Because the configuration file sometimes must be modified by users, providing a visual format for editing the configuration file is a good embodiment of user interaction of the software. We must find a visual method for the XML document. JTree in the Swing component in the Java language
I recently read the source code of "Enterprise express mail". The friends list of this project is implemented using jtree.
After understanding its writing method, I want to familiarize myself with the use of the jtree control. Therefore, I wrote a small exercise to show that the username and image path in the database are in the jtree, and users can be added and
Using the JTree componentSome concepts:
Root node: top-most point
Child nodes: nodes below the root node
Leaf node: When a node does not have any child nodes
Branch nodes: Conversely called
Construct JTree with Hashtable to TreeNode structure JTreeEach node on the JTree represents a TreeNode object. TreeNode itself is a interface.TreeNod
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;
Import Javax.swing.JFrame;
Import Javax.swing.JMenuItem;
Import Javax.swing.JOptionPane;
Import Javax.swing.JPopupMenu;
Import Javax.swing.JTree;
Import Javax.swing.tree.DefaultMutableTreeNode;
Import Javax.swing.tree.DefaultTreeModel;
/**
* A JTree maintenance code. Focus on
* 1) Get the way to select a node
* 2 the way to increase jpopmenu in
Steps to use JTree:
Create a node of a tree as the head node (its child nodes are also the same method of creation): Defaultmutabletreenode Headnode = new Defaultmutabletreenode ("First level");
Then the node is added using the JTree Setmodel method (the other nodes are added via the head node), and the head node is added to display.
Create a sub-node, add a sub-node with the Add method of the h
;
}Else{
Type = filedescriptiontext;
}
}
ReturnType;
}
This is the file type.
@ Override
PublicIcon getIcon (file F ){
This is an image representation.
In this way, the image and name we need after building this FileView can be obtained.
Then there is our Renderer:
PrivateClassFilesystemtreerendererExtendsDefaulttreecellrenderer {
Rewrite its method, set the image and name we get from FileView:
@ Override
PublicComponent gettreecellrenderercomponent (
In the homework have encountered about JTree and jtable linkage problem, and later on the Internet to check a lot of, are not written all the way, so wrote a small procedure for the consolidation and for the needs of the people reference
One implementation function
1 Display the data in the corresponding table
2 realizes the linkage between JTree and jtable.
3 Add and delete a row for the corresponding tab
dom|xml| data
Turn from: http://www.softhouse.com.cn/html/200410/2004102517145700001335.html
Using Jdom to manipulate XML data to generate an applet containing JTree
in our work, we often encounter the generation of tree components, if you are developing webapplication, purely JavaScript to generate tree components is very tedious, and the interaction is not very good. So many products enable applets to implement the functionality of the tree compon
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.