Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

get the depth of a node

Posted on 2006-04-26
7
Medium Priority
?
265 Views
Last Modified: 2010-03-31
hello there,

i am trying to get the depth of a node.but it is not working.on which ever node i click it returns 1.i am sending the code where i do this.please help.

class TreeListener implements TreeSelectionListener
    {
        public void valueChanged(TreeSelectionEvent tse)
        {
            handleTreeSelection();
        }
    }
   
    private void handleTreeSelection()
    {
        Object node = dbTree.getLastSelectedPathComponent();
        if (node == null || !(node instanceof TreeNode) || node.toString() == null)
            return;
        System.out.print(node.toString());
        TreeNode tp = (TreeNode)node;
        tableNode.getIndex(tp);
        System.out.print(tableNode.getDepth());
    }
0
Comment
Question by:zolf
  • 3
  • 2
  • 2
7 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 240 total points
ID: 16542193
>>tableNode.getIndex(tp);

What is 'tableNode'?
0
 
LVL 11

Expert Comment

by:WelkinMaze
ID: 16542239
Hi,

Why not
tp.getDepth()
instead of
tableNode.getDepth()
0
 

Author Comment

by:zolf
ID: 16542289


DefaultMutableTreeNode tableNode
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:zolf
ID: 16542297

cannot use TreeNode tp on getDepth();
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16542306
int depth = tableNode.getLevel();
0
 
LVL 11

Accepted Solution

by:
WelkinMaze earned 135 total points
ID: 16542341
I think, you may cast tp to some of the subclasses of TreeNode
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16542468
:-)
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question