Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How to make a JTree have multiple layers.

  1. #1
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default How to make a JTree have multiple layers.

    I was able to get children but how do I get grandchildren?

    I was able to do it with arrays, but it has the unacceptable side effect of having the array toString as the name, which isn't what I want.

    I've tried the JTree(TreeNode) constructor but when I tried something like this:

    names.add("Bob");
    names.add("Mike");
    names.add("Jim");





    DynamicUtilTreeNode dutn = new DynamicUtilTreeNode("Bubba", names);


    Object[] values = new Object[3];

    values[0] = dutn;
    values[1] = "Abanca";
    values[2] = "Davama";



    DynamicUtilTreeNode dutn2 = new DynamicUtilTreeNode("Rilli", values);



    jt = new JTree(dutn2);

    And it's not showing the third level.

    Bubba's children aren't showing up.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to make a JTree have multiple layers.

    How to Use Trees (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    javapenguin (May 31st, 2012)

Similar Threads

  1. Replies: 1
    Last Post: April 26th, 2012, 10:06 AM
  2. Replies: 6
    Last Post: December 9th, 2011, 05:53 PM
  3. Replies: 2
    Last Post: December 3rd, 2011, 04:40 AM
  4. How to make Multiple JUnit reports
    By GodspeedPR in forum Java Theory & Questions
    Replies: 0
    Last Post: July 22nd, 2011, 09:04 AM
  5. [SOLVED] Jtree help
    By sman36 in forum AWT / Java Swing
    Replies: 1
    Last Post: December 6th, 2010, 09:39 AM