How to use TreePath and to initialise a TreePath with a string?

Posted on 2006-04-26
Last Modified: 2008-03-06

I have the following code :
         Object[] ObjPath = new Object[3];
        TreePath pathSel = new TreePath(ObjPath);
        int numRow = jTreeAutoE.getRowForPath(pathSel);

and I get numRow=-1 instead of a positive number.
What is the right code in order to get the correct numRow from the path ?
I think the TreePath object is not correctly initialised.



Question by:pofpof98
    LVL 11

    Accepted Solution


    According to JavaDoc, -1 is returned if any of the elements in path are hidden under a collapsed parent.
    Are you sure that your tree is expanded and that the path is correct?

    Also you can check this one:

    Author Comment

    I think the path is incorrect because the  tree is expanded thanks to the following code

     for (int i=0;i<jTreeAutoE.getRowCount();i++){

    I 'd like, if possible, to have an example using
    Object singlePath or Object[] path

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    This is about my first experience with programming Arduino.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now