Are TreePaths only valid in the TreeModel they originate from?

I've got a JTree that lists our warehouse inventory, grouped by primary and secondary invenotry categories. (IE. "Printers" / "Laser" / "SomeLaserPrinter". ) The tree is populated through a SQL query.
I've got a checkbox that, when the value changes, decides if the tree should show or hide inventory categories that don't contain any inventory items at the moment.
What happens when I check/uncheck the box is that the tree is rebuilt from scratch according to it's value.
Now, if there is something selected in the tree when I click that checkbox, I want the same item to be selected and expanded when the tree is rebuilt. This is where I've been running in to problems.
The ActionListener for the checkbox is as follows:
//hideEmptyNodes is the JCheckBox
hideEmptyNodes.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent e ) {
       try { //inventoryTree is the tree
            TreePath tp = inventoryTree.getSelectionPath();
             // the InventoryTree.fillWithInventory(boolean hideEmpty) method
             // clears and populates the tree from a SQL query.
       inventoryTree.fillWithInventory( hideEmptyNodes.isSelected() );
            inventoryTree.expandPath(tp);
            inventoryTree.setSelectionPath(tp);
     } catch ( SQLException ex ) {
       LGRUtils.debugErrln( "Error filling tree." );
    } );This, does NOT work, for some reason. I tried creating the TreePath from the new TreeModel, but still the same:
hideEmptyNodes.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent e ) {
     try { //inventoryTree is the tree
          Object o = inventoryTree.getLastSelectedPathComponent();
           // the InventoryTree.fillWithInventory(boolean hideEmpty) method
           //clears and populates the tree from a SQL query.
       inventoryTree.fillWithInventory( hideEmptyNodes.isSelected() );
          TreePath tp = new TreePath(
              ((DefaultTreeModel)inventoryTree.getModel())
              //SimpleTreeNode extends DefaultMutableTreeNode and only
              //overrides the boolean equals(Object) method.
              .getPathToRoot((SimpleTreeNode)o));
          inventoryTree.setSelectionPath(tp);
     } catch ( SQLException ex ) {
       LGRUtils.debugErrln( "Error filling tree." );
    } );Quite frankly, I'm at a loss to how this stuff works. I've searched a bit around the forums, and I've found plenty of other people who have problems with setting the selection paths of trees. None of them have gotten their problems solved in any uniform way, it seems the solution varies from user to user.
Any pointers to a way of doing this, and making it work, would be greatly appreciated!
-christig

First thing I would tell you is that if you will not rebuild a tree from scratch, you will not have this problem!
Denis Krukovsky
http://dotuseful.sourceforge.net/

Similar Messages

  • If i buy an unlocked iphone 4s in the usa will it work in Australia? and will the warranty be valid in astralia as i have been told that apple have a world wide after sales service but also been told warranties are only valid in the country of purchase

    If i buy an unlocked iphone 4s in the usa will it work in Australia? and will the warranty be valid in astralia as i have been told that apple have a world wide after sales service but also been told warranties are only valid in the country of purchase? Cheers

    Each country is a separate business. If Apple in Australia fixes a phone purchased in another country it reduces their profit. The good news is that Apple stores will frequently replace phones purchased in other countries under warranty, but they are not required to do so. Some countries are more liberal than others. India never does, for example.
    Why don't you just buy it in Australia? The price difference can't be that great.

  • I uploaded photos in .jpg format to my iPad, but now all of those photos appear as .ithmb files and cannot be opened, even on the thumbdrive they originated from. How do I get them back to .jpgs?

    I uploaded photos in .jpg format to my iPad, but now all of those photos appear as .ithmb files and cannot be opened, even on the thumbdrive they originated from. How do I get them back to .jpgs?

    Sorry, should've mentioned some more information. I synced the ipad to the folder of photos. The original photos had file names like "_MG_4865.jpg" and after syncing the folder in Itunes, all files were now found in a folder called "iPod Photo Cache" which was filled with many folders with labels like "F23" etc. (There were ALOT of photos.) In those folders there are several files with names like "T343.ithmb". Not a .jpg to be found and I can't view any of the photos.

  • How do I download an app I previously had on an older device, not utilizing my cloud or itunes backup. I want to download the app as if it were the first time. Right now it's only giving me the option to download from the cloud when I go to the app store.

    How do I download an app I previously had on an older device, not utilizing my cloud or itunes backup. I want to download the app as new as if I had never had it before. When I go to the app store, it only gives me the option of downloading from the cloud with the cloud icon?

    When you download something from the iCloud, it is a brand new licensed copy. Your iCloud account just contains a notation that you have this app. It isn't storing an actual copy of the app from your Mac.

  • I am trying to upload my PDF file from my IBooks but its only giving me the option to upload from my pictures/gallery. How do I get it to where I can upload PDF files from my iBook or how do I transfer my PDF files to my pics?

    I am trying to upload my PDF file from my iBooks but its only giving me the option to upload from my pictures/gallery. How do I get it so I can upload from my iBooks or move my PDF files to my gallery so I can upload it?

    I'm having the same issue. I saved a PDF from an email into iBooks. I'm on apple applying for a job but the only option the upload button has is from the Photos file. How ironic right? Luckily I'm in Logistics and not an IT specialist applying for this job! Lol. Does anyone know the fix?

  • Hyper-v cannot be installed: A hypervisor is already running: VMware Workstation and Hyper-v are not compatible. Remove the Hyper-V role from the system before running Vmware Workstation

    When I try to go to Control Panel\Programs and click on turn windows features on/off and , it shows ticks on hyper-v is removed.
    Hyper-v platform Is grayed out and When i move the mouse point to  Hyper-v platform it shows a message.
    "Hyper-v cannot be installed: A  hypervisor is already running"
    When I try to install vmware it says..
    VMware Workstation and Hyper-v are not compatible. Remove the Hyper-V role from the system before running Vmware Workstation..

    I dont feel you can do this. I have also tried what you tried and ended up with a failure.. So had to stick with vmware in one instance and for other instance hyper v... 
    For further details raise your question here http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverhyperv
    and
    https://communities.vmware.com/community/vmtn/developer/forums
    Good luck.. 

  • Why is my Apple ID only valid for the Apple store in one country (Ireland) even though I have moved to and live in the USA?

    I have moved from Ireland to the USA and now (legally) live in Seattle. When I try to login to the iTunes store here in the USA, I get a message telling me that my Apple ID is only valid for purchases from the Ireland iTunes store. What moron put in a restriction like that? Apple is now telling me that although I can legally move from one country to another and take up residence, I can not travel globally with my Apple ID? What use is having an Apple ID then as I can travel and buy globally with Amazon?

    Do NOT create another ID.  Change the country of your present ID.
    App Store Frequently Asked Questions (FAQ) - http://support.apple.com/kb/HT2001 when using iTunes --> "To change countries, scroll to the end of the iTunes Store home page and click the flag indicating the current country. To choose a different country, click the appropriate flag."
    iOS: Changing the signed-in iTunes Store account - http://support.apple.com/kb/HT1311  - Change your iTunes Store country: "Sign in to the account for the iTunes Store region you'd like to use. Tap Settings > iTunes & App Stores > Apple ID: > View Apple ID > Country/Region."
    You will, of course, need to change your address and enter valid credit card information after you have changed the settings.
    iTunes Store: Changing Account Information - http://support.apple.com/kb/HT1918
    Further tips on changing country - https://discussions.apple.com/message/20029737 - problems you encounter when changing iTunes country
    Realize, however, just as you can no longer visit your old public library in Ireland you also no longer have access to the store or your purchases made there.  You can continue to use them as they are on your computer now but that makes it all the more important you maintain backups in case of loss.  If you upgrade an app I think you will have to pay for it again since you no longer have access to the Irish Store.

  • Hi Apple - Surely with the internet being global you can let "customers" select the country they dsownload from.  I was goung to use Itunes but having tried twice to get UK downloads in Spain have given up on Itunes.  How many others have.

    I would really like Apple to take notice of the number of "customers" who want to download in their own language, not the language of the country they are in.
    My Laptop was bought in England and my internet is an English provider.  My bank account is in England.  I happen to live in Spain. So why can't I download from an English Itune Store.  I have not had this problem wih any other free App or webb based account, and I have many. 
    I have seen lots of posts saying it can't be done but Apple please pleae tell me why.
    Apple must be loosing out on thousands of customers and heaven knows how much revenue.
    Come on everyone get all your friends who have the same problem to let Apple know.

    You are NOT addressing Apple here at all.
    We are all itunes users just like you.

  • Why are key functions, such as the "back" button, missing from Firefox after involuntary update?

    I noticed that there is a new version of Firefox on my computer, different from the last time I had my computer on. There are few issues that I have noticed thus far. 1) The back" and "forward" buttons are disabled. 2) Whenever I open a website the address bar is missing the URL. 3) Firefox doesn't save my tabs and I lost all of my tabs from the previous session.
    Please help me. This makes browsing a frustrating task.

    Problems with bookmarks and history not working properly can be caused by a corrupted places.sqlite database file.
    You can check for problems with the places.sqlite database file in the Firefox Profile Folder.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_fix-the-bookmarks-file
    See also:
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    *http://kb.mozillazine.org/Corrupt_localstore.rdf
    It is possible that there is a problem with the files sessionstore.js and sessionstore.bak in the Firefox Profile Folder.
    Delete the sessionstore.js file and possible sessionstore-##.js files with a number and sessionstore.bak in the Firefox Profile Folder.
    *Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    Deleting sessionstore.js will cause App Tabs and Tab Groups and open and closed (undo) tabs to get lost, so you will have to create them again (make a note or bookmark them).
    *http://kb.mozillazine.org/Multiple_profile_files_created
    If you keep having problems with your current Firefox Profile Folder then try to create new profile or reset Firefox.
    Create a new profile as a test to check if your current profile is causing the problems.
    See "Creating a profile":
    *https://support.mozilla.org/kb/profile-manager-create-and-remove-firefox-profiles
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Profile_issues
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
    If the new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox
    You can also try to reset Firefox:
    *https://support.mozilla.org/kb/Basic+Troubleshooting

  • I signed up for Adobe Acrobat Standard only to find the software option switched from Mac to Windows during the sign up process - Refund Please

    This was started from my Trial Acrobat installation on my Mac, following a pop up to register on my Mac and then a browser session on my Mac! 
    I have cancelled the monthly plan for the Windows version and successfully completed the process for the Mac version, but now I need my refund for the 1 month of the Windows version that I didn't want and didn't ask for and can't use.  I rang the number but was on hold for 32 minutes before giving up. 
    I clicked on the link under the cancellation in my Adobe account but that ends up in a 1000 option black hole support site. 
    How do I proceed, without wasting another hour of my life? Thanks.

    Re The first Link:
    Return, cancel, or exchange an Adobe order
    Cancel your membership or subscription | Creative Cloud
    I have done this.  I just need the refund that was mentioned on the bottom of the page that I have already cancelled on.  None of the other links on that page are relevant and none mention the word "Refund"
    Re; The second link, is this a UK 0800 number or a US Number?  I am in the UK.  Will I be on hold for 32 minutes again if I ring this number?

  • About emails linked to the fora they come from

    I would like to understand the relationship between the questions answered in the fora and the subsequent emails I receive as a result of it. I can see the content of those emails in the relevant forum I attend, but when I answer those emails my content does not appear in that forum, yet the bottom of the emails I receive stipulate that to reply the email is the prefered manner to add to the forum.
    ie "To post a reply to the thread message, either reply to this email (recommended) or visit the message page:"
    This bothers me a little as when I reply an email I tend to be more personal to the person who sent it to me, but if I know it will be also in the thread, which I thought it should I would try to alter my reply appropriately.
    I remember vaguely reading in one of the first such email I received (in the header perhaps) something about brackets not to be removed but can't find where it is anymore.
    thank you for any light ont he subject
    MM
    Not part of the conversation: I copied the above bold text from one of those email, but right click in this space did not show "Paste"? (yes Ctrl V did work

    The forum is designed to be accessed either via web or via email (or both).  So, you can if you desire; read, respond, and start new threads all through email.  When you reply via email it is the same as posting to the thread.   You are not replying to an individual.
    Please see the forum FAQ for some other details:
    Forum FAQ

  • HT1727 I downloaded my previous song purchases to my new MacBook and they are all only parts of the songs.. How can I fix this?

    I downloaded my previously purchased songs to my new macbook, but only parts of each song are available. How do I fix this problem?

    Delete the Song(s) and re-download...
    See Here  >  Download Past Purchases
    http://support.apple.com/kb/HT2519
    If no joy... Contact iTunes Customer Service
    Apple  Support  iTunes Store  Contact Us

  • Hope they are not charging me for the service they don't fix?

    HELLO to day 6 could be seven of no 4 g coverage on my VL600 broadband . Another run around call yesterday where of course the ask questions to see if you did anything wrong then the same things are done..{ turn off the comupter disconnect the VL600 ,, WAIT A FEW MINUTES plug the VL600 back in ..do you have 4g now....NO....well there is a ticket for this problem that was started on march 29 .... 6 days ago....3 times on the phone..it's the same thing....2 times in a chat room  and no results... plus yesterday when you call verizon you press numbers and state what you are having problems with.. they connect you to someone to handle the problem but I loved yesterdays call ,,... after all the trys of getting my 4 g back up he text me a number on my iphone  to call for TECH SUPPORT  ... WHO was i switched to on the last 3 calls I made  .... my big question is I know this is only a forum but chatting with some one from verizon 2 times.. calling 3 times where do i go next to get my broadband fix . fed up in wolcott ny

    Wondering if it is a device issue. I would recommend visiting a corporate store with the laptop and VL600. It is usually easier to get a fix when someone can see what is going on. It is quite possible you need a replacement 4G SIM card. If they can't fix it in store and there is no damage to the device and you are still under warranty the rep can order a replacement if you qualify for it. I am not saying that you will get a replacement because I don't know your account specifics.
    I know it's frustrating but calmly going to the store may be the solution to this issue. I hate trying to do tech support over the phone.

  • Are user events valid before the event structure executes?

    If I create and register for a user event and immediately generate that event before my event structure has seen the registration refnum, is the event still guaranteed to be seen by the structure? That is, are events queued up? It works but I am wondering if I can rely on it. I am very sure that I can but I am creating some production code and want to be assured that I am not just taking advantage of a bug.
    A picture is worth a thousand words.
    =====================
    LabVIEW 2012
    Solved!
    Go to Solution.

    Generally, Felix's explanation is correct and the queue exists from the moment the register node executes, so the answer is that you can rely on this.
    You should, however, be aware that when playing with dynamic registration you can experience some unexpected side effects, as you can see, for example, in this LAVA thread - http://lavag.org/topic/13607-dynamic-event-reregistration/
    Another example would be this - http://lavag.org/topic/13970-unexpected-event-structure-non-timeout-behavior/page__view__findpost__p...
    Or what happens if you split the registration refnum to more than one event structure (hint - NEVER do that).
    Try to take over the world!

  • Labview buttons are triggered only after rerun the vi

    I have a vi actually to behave like a control panel.
    i created each action with a button.
    for example:
    Lockbutton, unlockbutton...
    when run the vi, i click on lockbutton, it locks.
    then after it locks, when click on unlock button, no value is parsing at unlock button.
    what's is wrong with my vi?
    help me..
    Attachments:
    Panel01.vi ‏83 KB

    instead of using case structure of each button, i use event structure?
    Yes - that will make things easier to manage.  I would do some reading on it before you jump in, you may decide to use a producer/consumer with events should you require that the FP remain responsive when performing a time intensive operation.
    about the notifier refnum, how to determine it?
    each case would have its own refnum?
    For this I just meant you can fork the wire for the Refnum.  Something like this:
    Regards,
    Peter D

Maybe you are looking for

  • IPOD Mini is not recognized by my PC

    Help! I can't restore/update my Ipod Mini because my PC won't recognize it. When I reset the Ipod I get a folder/! or an Apple symbol - nothing more. The computer seems to be able to charge the Ipod, but doesn't recognize it - doesn't start Itunes, s

  • Just installed os x 10.8.3 and can no longer access icloud.

    I can no longer access icloud, mail, etc. after updating to 10.8.3.  On the other hand, I seem to be okay on my iphone.  Anyone else have this problem or any ideas. Thanks

  • Open fillable form on iPad from Website

    I have a form on my schools website- http://s3.amazonaws.com/scschoolfiles/480/application_form.pdf -that will not open on an iPad, or in any web browser. I can download and open the form, but the teachers at the school would like their students to f

  • 1 have 1 GB RAM on my computer. Firefox is using 750MB and is slooooooooow.

    When I shut down Firefox and restart, it uses 125MB of RAM, but within 45 minutes it is at 350MB and in 2 hrs it increases to 750MB, effectively locking my computer up.

  • Question about Cluster/DSync/Load Balance

    According to the admin doc of iplanet, primary server is the "manager" for data sync, is there any impact on load balance when the iAS run as primary or backup? will the primary kxs get the request first and do dispatching? Thanks. Heng