1 // *** HideableMutableTreeNode ***
3 import javax
.swing
.tree
.*;
6 * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code>
7 * implementation that works with <code>HideableTreeModel</code>.
9 public class HideableMutableTreeNode
extends DefaultMutableTreeNode
{
11 * The node is visible flag.
13 public boolean bIsvisible
= true;
14 private static final String SDUMMY
= "Dummy";
18 * Creates a tree node that has no parent and no children, but which
21 public HideableMutableTreeNode() {
26 * Creates a tree node with no parent, no children, but which allows
27 * children, and initializes it with the specified user object.
29 * @param userObject - an Object provided by the user that
30 * constitutes the node's data
32 public HideableMutableTreeNode(Object _userObject
) {
37 * Creates a tree node with no parent, no children, initialized with the
38 * specified user object, and that allows children only if specified.
40 * @param _userObject - an Object provided by the user that describes the node's data
41 * @param _ballowsChildren - if true, the node is allowed to have childnodes -- otherwise, it is always a leaf node
43 public HideableMutableTreeNode(Object _userObject
, boolean _ballowsChildren
) {
44 super(_userObject
, _ballowsChildren
);
48 * Checks if the node is visible.
50 * @return true if the node is visible, else false
52 public boolean isVisible() {
53 return this.bIsvisible
;
57 * Sets if the node is visible.
59 * @param returns true if the node is visible, else false
61 public void setVisible(boolean _bIsVisible
) {
62 this.bIsvisible
= _bIsVisible
;
66 public void addDummyNode(){
68 DefaultMutableTreeNode oDefaultMutableTreeNode
= new DefaultMutableTreeNode(SDUMMY
);
69 add(oDefaultMutableTreeNode
);
74 public boolean removeDummyNode(){
75 boolean breturn
= false;
76 if (getChildCount() == 1){
77 DefaultMutableTreeNode oDefaultMutableTreeNode
= (DefaultMutableTreeNode
) getChildAt(0);
78 if (oDefaultMutableTreeNode
!= null){
79 if (oDefaultMutableTreeNode
.getUserObject().equals(SDUMMY
)){