Home | » | Java | » | Advance Java | » | Java Swing II | » | JTree |
---|
A control that displays a set of hierarchical data as an outline. A specific node in a tree can be identified either by a TreePath (an object that encapsulates a node and all of its ancestors), or by its display row, where each row in the display area displays one node. An expanded node is a non-leaf node (as identified by TreeModel.isLeaf(node) returning false) that will displays its children when all its ancestors are expanded. A collapsed node is one which hides them. A hidden node is one which is under a collapsed ancestor. All of a viewable nodes parents are expanded, but may or may not be displayed. A displayed node is both viewable and in the display area, where it can be seen.
JTree displays its data vertically. Each row displayed by the tree contains exactly one item of data, which is called a node. Every tree has a root node from which all nodes descend. By default, the tree displays the root node, but you can decree otherwise. A node can either have children or not. We refer to nodes that can have children — whether or not they currently have children — as branch nodes. Nodes that can not have children are leaf nodes.
The following JTree methods use "visible" to mean "displayed":
- isRootVisible()
- setRootVisible()
- scrollPathToVisible()
- scrollRowToVisible()
- getVisibleRowCount()
- setVisibleRowCount()
- isVisible()
- makeVisible()
The below program show how to use JTree in java swing...
C:\>jdk1.4\bin>javac JTreeDemo.java
C:\>jdk1.4\bin>java JTreeDemo
|
||
Download Complete Program |
No comments:
Post a Comment