Going through all the nodes children (JTree)

Hello all,
I'm detecting clicks on a JTree, and I want a method that goes from that node to the end of the tree (all the leaves). The method will be invoked if the node has children of course, I want to do this recursively but I don't know how. Can anyone help me;
Thanks a lot in advance
Alejandro

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.util.Enumeration;
public class Test extends JFrame {
  public Test() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    JTree jt = new JTree();
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    jt.addMouseListener(new MouseAdapter() {
      public void mouseReleased(MouseEvent me) {
        JTree jt = (JTree)me.getSource();
        TreePath tp = jt.getClosestPathForLocation(me.getX(), me.getY());
        TreeNode tn = (TreeNode)tp.getLastPathComponent();
        System.out.println("-------------Start Recursion---------------");
        showNode(tn);  // same as depthFirstEnumeration()
        System.out.println("-------------Start Enumeration---------------");
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
        Enumeration e = dmtn.breadthFirstEnumeration();
        while (e.hasMoreElements()) System.out.println(e.nextElement());
    setSize(400,400);
    setVisible(true);
  private void showNode(TreeNode tn) {
    System.out.println(tn);
    for (int i=0; i<tn.getChildCount(); i++) showNode(tn.getChildAt(i));
  public static void main(String args[]) { new Test(); }
}

Similar Messages

  • I can't sync my ipod to itunes. It looks like it is going through all the steps to sync but nothing happens. The music I moved around is not going where it should

    I can't sync my ipod to itunes. It goes through all the steps to sync but it does not sync. The music I moved around does not go where I put it. It shows up in itunes (when changing music around) but does not change it on my ipod. Can someone help me?

    Sync Session Failed to Start iTouch iOS5: Apple Support Communities
    iphone could not be synced sync session failed to start...: Apple Support Communities
    and
    Can't connect to the iTunes Store

  • I did a full system restore to my phone along with the new 7.0 update. Now I went to restore my phone setting back through Itunes and it goes through all the steps but when it is completed it wont get past the "Connect to Itunes" screen

    I did a full system restore to my phone along with the new 7.0 update. Now I went to restore my phone setting back through Itunes and it goes through all the steps but when it is completed it wont get past the "Connect to Itunes" screen

    So what happens when you connect to iTunes?

  • Unable to Download Apps after going through all the troubleshooting. What do I do next?

    Unable to Download Apps after going through all the troubleshooting. What do I do next?

    Also, see here
    http://decipher-media.blogspot.co.uk/2011/05/itunes-sync-vs-backup-how-to-ensure -you.html
    http://support.apple.com/kb/HT4946

  • How do I stop my cursor from selecting things on the page? It shows up like I want to type something and when I press the down key it goes through all the words like its a word document.

    How do I stop my cursor from selecting things on the page? It shows up like I want to type something and when I press the down key it goes through all the words like its a word document.
    == This happened ==
    Every time Firefox opened
    == June 27, 2010

    You have '''caret browsing''' enabled - that preference appears as set in your Troubleshooting Information.
    http://kb.mozillazine.org/Accessibility.browsewithcaret
    Hit the '''F7''' key to disable '''''caret browsing'''''.

  • My CS2 Illustrator goes through all the motions to open but then at the end, nothing happens. It has

    My CS2 Illustrator goes through all the motions to open but then at the end, nothing happens. It has been working well for years, but then out of the blue it just won't open. I reinstalled it and the it still won't open. HELP! I'm under a big art deadline and this is ridiculous. Thanks.

    Or you may try to Move the folder or the Other options
    In the old days, deadlines were dead serious.

  • I have a mid to late2007  MacBook Pro core 2 Duo   But can't seem to load mountain lion   goes through all the steps then freezes at reboot

    I have a mid to late2007  MacBook Pro core 2 Duo   But can't seem to load mountain lion   goes through all the steps then freezes at reboot
    Everything I read said Mid to Late 2007 models od the MacBook Pro with a Core 2 Duo 64 Bit processor would run Moutain Lion

    I have a mid to late2007  MacBook Pro core 2 Duo   But can't seem to load mountain lion   goes through all the steps then freezes at reboot
    Everything I read said Mid to Late 2007 models od the MacBook Pro with a Core 2 Duo 64 Bit processor would run Moutain Lion

  • Looping through all the Nodes at any Particular Level Specified

    Dear Forum Members,
    I have an XML File in the database in a Column of type XMLTYPE.
    The Format is given below
    <XML-SSDFILELIST>
    <Training>
    <BRKCD_STMNSWTINVIN_C Key="6707">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </BRKCD_STMNSWTINVIN_C>
    <BRKCD_STREDSWTINVIN_C Key="6708">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </BRKCD_STREDSWTINVIN_C>
    <VSACD_TIPER_C Key="7285">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </VSACD_TIPER_C>
    <VSSCD_NTHRESPLA_C Key="6266">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </VSSCD_NTHRESPLA_C>
    <VSSCD_QTHRESPLA_C Key="6267">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </VSSCD_QTHRESPLA_C>
    <VSSCD_VDFL_C Key="6269">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </VSSCD_VDFL_C>
    <VSSCD_VMAX_C Key="6270">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </VSSCD_VMAX_C>
    <VSSCD_VMIN_C Key="6271">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </VSSCD_VMIN_C>
    <VSSCD_VTHRESPLA_C Key="6272">
    <FINISHED><![CDATA[This is a Finished data ]]></FINISHED>
    <CONTACT-NUMBER><![CDATA[This is a CONTACT-NUMBER data ]]></CONTACT-NUMBER>
    <DEFAULT></DEFAULT>
    <MIN></MIN>
    <MAX></MAX>
    <UNIT></UNIT>
    <FORMULA></FORMULA>
    <FORMULA-DESC></FORMULA-DESC>
    <ADVANCED-FORMULA></ADVANCED-FORMULA>
    <INTERNAL-ADAPT-DESC></INTERNAL-ADAPT-DESC>
    <DATA-DESC-REPORT></DATA-DESC-REPORT>
    <REV-DESC></REV-DESC>
    </VSSCD_VTHRESPLA_C>
    </Training>
    </XML-SSDFILELIST>
    Is there any way I can Loop through all the Child records at 3rd Level(Bolded Level in the File).
    Regards
    Madhu.

    check this blog,
    http://www.oracleappshub.com/11i/oracleapps-responsibility-vs-sap-functions/
    Re: How to change OM responsibility as read-only in oracle applications 11i
    read only responsibility-user

  • I cannot access Facebook after going through all the recommended ways to fix the problem. Help me.

    I went through all the reccomended ways to try and allow Firefox to access the cite. however after i do that ill try and access the web citie and everytime i get an error page. It says connection was reset. So i went back to Firefox support and did the recommended way to fix it again and still it did not fix my problem. How to i fix this issure?

    I dont understand the answer
    '''''""The problem can be solved by opening FF and choosing Tools...Add On's...select the SEARCH addon and choose UNINSTALL...restart FF browser when asked, then reload Mobsters. This worked for me. The suggestion on the 404 that says to remove Search via Add/Remove Programs is completely BS, as Search doesnt show there. ""'''''

  • I have tryed to instal upadate to firefox 6.0.2 like 5 times lately, and it goes through all the motions of doing an update, and even told me it was complete, then it still is the last version!

    i have tried to install the newest version about 5 times now, everytime that i try, it goes through the steps, all the way to where it says finish! i have tried doing it standard install and custom install. i've tried doing it straight from other websites telling me that i need an updated version... ie. hotmail, facebook, and i've also gone to mozilla.com, and it always does the same thing, what am i doing wrong?

    Something that you have installed has changed your User Agent or is keeping your User Agent from updating with the new install/update of Firefox. I suspect that it is Fast Browser Search which is shown as part of your User Agent. To get rid of Fast Browser Search do the following:
    #Close Firefox (Firefox button > Exit '''''OR''''' File > Exit)
    #Open the Vista Control Panel and remove/uninstall "Fast Browser search protection" and "Fast Browser Search" (MyWebTatoo)
    #*See --> http://windows.microsoft.com/en-US/windows-vista/Uninstall-or-change-a-program
    #*Your User Agent: ''Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729) '''<u>FBSMTWB</u>'''''
    #*What is a User Agent: http://en.wikipedia.org/wiki/User_Agent
    #Start Firefox
    #*Reset your User Agent following the instructions in the article below:
    #**See --> [https://support.mozilla.com/en-US/kb/websites%20or%20add-ons%20incorrectly%20report%20incompatible%20browser#w_reset-your-user-agent Reset your user agent]
    #*Check your Firefox version:
    #**See --> [https://support.mozilla.com/en-US/kb/Finding+your+Firefox+version Finding your Firefox version]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check: https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.com/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.com/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.com/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.com/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • Firefox crashing 6.0.2, a dozen times or more a day even after starting in safe mode, disabling add-ons and going through all the guides on Firefox crashes

    I've done 3 uninstalls, 2 of them all the way, one keeping the customizations. I have reinstalled each time. I've updated my plug-ins, restarted in safe mode with everything disabled (including plug-ins and add-ons) and am going nuts trying to figure out why Mozilla keeps crashing. It ALWAYS crashes on the Firefox add-on page, it sometimes crashes on Youtube and Facebook and rarely on google pages. I have ran MalwareBytes, SuperAnti-Spyware, Norton scans and Norton Power Eraser, they all say that I am clean, my computer is clean and the worse thing they can find are cookies.
    Please help. Thanks!!

    Some of the IDs are: bp-4114edef-c971-4186-be78-d7caf2110917, bp-75ebb8f1-eb77-48c5-8459-855d92110917, bp-9058c487-b913-4932-a6f6-4fbb12110917, bp-9e06e3c8-43ec-4f78-ad70-de51c2110917, bp-c5af28a9-ce6c-4ab7-9c66-07d552110917, bp-579cc0c9-d018-4645-9a05-377f32110917.
    Thanks!

  • HT201210 I was in the process of upgrading to ios6 after going through all the process, the last thing to come up was a picture of the iTunes icon in blue with a USB lead leading up to the icon?  All I can do is to switch it off, HELP

    Need help was trying to up grade from ios5.1.1 to ios6 after installing for over 40 minutes the final screen came up with the blue iTunes icon and a USB lead leading to it.  All I can do is to switch it off.  iPad 2 will not turn on to the home screen, it keeps going to the iTunes icon with the lead. When I plug the iPad in to my mac all I get is that the iPad is in recovery mode.  HELP!!

    Also, see here
    http://decipher-media.blogspot.co.uk/2011/05/itunes-sync-vs-backup-how-to-ensure -you.html
    http://support.apple.com/kb/HT4946

  • Youtube freezes even after going through all the solutions

    After, deleting cookies, resting firefox, re installing firefox, factoring defaulting firefox literally exhausting every solution on your website when i launch youtube it crashes my firefox browser, even the borders of the window for firefox goes crazy. At this point im so frustrated im ready to permanently uninstall firefox

    Have you tried disabling HWA?
    You might need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    Then perform these steps:
    *Click the orange Firefox button at the top left, then select the "Options" button, or, if there is no Firefox button at the top, go to Tools > Options.
    *In the Firefox options window click the ''Advanced'' tab, then select "General".
    *In the settings list, you should find the ''Use hardware acceleration when available'' checkbox. Uncheck this checkbox.
    *Now, restart Firefox and see if the problems persist.
    Additionally, please check for updates for your graphics driver by following the steps mentioned in the following Knowledge base articles:
    * [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    * [[Upgrade your graphics drivers to use hardware acceleration and WebGL]]
    Did this fix your problems? Please report back to us!
    Thank you.

  • When i sync my phone it goes through all the photo's then a window pops up which says that itunes has stopped working and the closes itunes down, i have tried syncing a few times and it just keeps doing the same but says windows MAY send a solution, help

    i am getting really frustrated with syncing and updating my iphone, everytime i sync when the photo's have sunk a window pops up and says itunes has stopped working and closes the programme, it also says that windows may send me a solution but they never do !!!! please can someone help me

    Hello Suzanne,
    Thank you for providing the details of iTunes unexpectedly quitting.  You have taken some really good troubleshooting steps already.  I found an article with additional steps you can take to further isolate and troubleshoot an issue like the one you described:
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/ts1717
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • I have trying for days to download Firefox 4.1. It goes through all the motions, but when it gets to the final step, it can't connect with the download server. What should I do? It keeps telling me this download is strongly recommended.

    It downloads everything, but when I re-start, it can not connect to the download server.
    I've left it open and it never connects.

    Your UserAgent indicates that you used Firefox 3.6.17 to post here. <br />
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
    What does it say about the version of Firefox you have in '''Help > About Firefox'''?
    If it says Firefox 4.0 or 4.0.1, see if this helps you: <br />
    https://support.mozilla.com/en-US/kb/Websites+or+add-ons+incorrectly+report+incompatible+browser

Maybe you are looking for