JTree.isExpanded(0) - true, but jTree.collapseRow(0) - doesn't work

<code>
if (jTree.isExpanded(0) ) {
System.out.println("Expanded!")
} else {
System.out.println("Collapsed!")
</code>
It says. Expanded!
So,
<code>
if (jTree.isExpanded(0) ) {
System.out.println("Expanded!")
jTree.collapseRow(0);
jTree.repaint();
} else {
System.out.println("Collapsed!")
</code>
But it doesn't work! Why?

If you want to control the icon that's rendered at each node you should write your own TreeCellRenderer.
How you determine which icon to show is dependent on your application. What are you putting into the tree nodes that lets you decide which icon to show?
You'd code it something along these lines:
public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
     public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean focus) {
     JLabel renderer = (JLabel) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, focus);
     Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
     // TODO: change these based on the node's user object
     renderer.setText(...);
     renderer.setIcon(...);
     return renderer;
}Read up about cell renderers in the Swing Tutorial for more information.
Incidentally, if you use this approach you shouldn't need to customise the root node as indicated in another post since the user object of the root node will help you choose the icon for it.
Hope this helps.

Similar Messages

  • Hi guys, my iPhone 4S (ios 7.0.2) can't connect wi-fi. I've already reseted Network Settings, but Wi-fi still doesn't work. how can I fix it? thank you!

    hi guys, my iPhone 4S (ios 7.0.2) can't connect wi-fi. I've already reseted Network Settings, but Wi-fi still doesn't work. how can I fix it? thank you!

    Thank you!
    doesn't like one at Starbucks or McDonald's...
    I can not activate or deactivate the Wi-fi button ... I don't know how I can explain... the wi-fi is always OFF.
    I've reset the network settings and restored by itunes... but I'm still without wi-fi ...

  • In my dock there was this weird program called "tutorial". While throwing away this program I had to fill in my password. Afterwards I tried to change my password, but my old password doesn't work anymore. Who can help?

    In my dock there was this weird program called "tutorial". While throwing away this program I had to fill in my password. Afterwards I tried to change my password, but my old password doesn't work anymore. Who can help?

    What was this program for, or did you just assume it's something you shouldn't have and therefore arbitrarily decide to "throw it away"? Exactly how did you supposedly throw it away?
    If you didn't change your administrator password, there's no reason it shouldn't work now, so that suggests you did something else, or changed it and then forgot what it was.
    You can't recover that password; you can only change it. To do that, you would need to boot from your Snow Leopard DVD, choose your language, then choose Reset Password from the Utilities menu in the top menu bar.

  • I get this message when I try to open my google shared docs this week: "A browser error has occurred. Please hold the Shift key and click the Refresh button to try again." - but that click/refresh doesn't work either. What's up?

    # Question
    I get this message when I try to open my google shared docs this week: "A browser error has occurred. Please hold the Shift key and click the Refresh button to try again." - but that click/refresh doesn't work either. What's up?

    The backend end is in serious pain....on many levels.
    Try this: Connection Problems Form

  • I am using CS4. Can I open CS6 files? I am receiving "plug-ins not available on your system" messages and I'd like to open anyway but clicking on OK doesn't work.

    I am using CS4. Can I open CS6 files? I am receiving "plug-ins not available on your system" messages and I'd like to open anyway but clicking on OK doesn't work.

    InDesign CS4 can open .indd, .indt  and .inx files from earlier versions, but not from later. It should, however, be able to open .idml files saved or exported from newer versions, with the understanding that unsupported features will be lost, text will probably reflow due to differences in texts engines between versions, and that the greater the gap between versions the more likely there are to be noticeable differences from the original. You will need to be sure CS4 is at version 7.0.6 to read the .idml.

  • I have installed 0S5 but restoring the backup doesn't work. the following messages appear: An error accurred while restoring this iphone (-20)  because the backup was corrupt or not compatible with iphone being restored (my iphone 3GS)

    I have installed 0S5 but restoring the backup doesn't work. the following messages appears: An error accurred while restoring this iphone (-20), followed by another message:  because the backup was corrupt or not compatible with iphone being restored (my iphone is 3GS), I tried restoring the factory settings and then restore the backup, but the same problems and I have lost all my contacts, pictures etc

    Hi Ckuan,
    Thanks a lot for your advice.    
    Deleting the correupted back up means to delete the information of one month since the last back up I made is one month ago.....right? 
    This back up I made right before I restored my iphone.  During the restore however my OS was upgraded to 5.1.1. and reading the comments on the internet it seems I am not the only one whom experience this problem. 
    Can it be that if I downgrade my OS back to 5.1. the back up will not be considered as corrupted?  If so, how do I downgrade the iphone?
    Thanks in advance.

  • My iPhone has stopped working over wifi. It was working till late night yesterday and in monring it stopped. I thought that it may be problem in my internet. But noticed that it doesn't work with office wifi as well. Have done some of the reset option.

    My iPhone has stopped working over wifi. It was working till late night yesterday and in monring it stopped. I thought that it may be problem in my internet. But noticed that it doesn't work with office wifi as well. Have done some of the reset option.

    Follow the steps here. If nothing works, make an appointment at an Apple store or with whoever handles iPhone warranty where you live:
    http://support.apple.com/kb/TS1398

  • HT4859 I recently had to restore my phone to factory settings - I did a back up first but now my phone doesn't work, where can I find my contacts? Where can I find the back up?

    I recently had to restore my phone to factory settings - I did a back up first but now my phone doesn't work, where can I find my contacts? Where can I find the back up?

    Did you try restoring your iCloud backup?

  • I try everything but the wifi sync doesn't work, please help...

    Hello,
    I tried:
    Restore my iPhone 4 (iOS 5.1.1)
    Check router settings (tried default settings and reset also)
    Check everything in iTunes
    Connect to different wifi
    Upgrade my MacBook Air to Mountain Lion (1.0.8.0)
    ....etc.
    I have everything latest, I read almost everything about it, tried tweaks, but none of this doesn't work.
    When I've got my iPhone connected to Mac through USB with wifi enabled, sync work well...
    Everything worked fine all the time and from day to another it doesn't work anymore.
    It's a pain in the ***, I have already lost my mind. Nothing work.
    I appreciate any help from you guys, thank you very much
    (sorry for english, I'm czech)

    I probably do not understand your question. But try this, maybe this is what you want. Try iCloud on your iPhone.
    Tap Settings App > Wi-Fi > turn it ON. Then go back to Settings and below General tap > iCloud. Make sure your account is there, turn ON what you like and then at bottom select Storage & Backup. Hopefully this will help you.

  • Don't want to use new Numbers, but 'get info' fix doesn't work

    Hi All,
    I made the mistake of installing the new Numbers a month or two ago. I don't want to use the new Numbers because I need to work on the same documents on older machines that won't work with the new Numbers. On my machines with both versions of Numbers, I want to be able to just double-click on the documents and open with the older version. The usual fix is to use get info on a document, select the app I want to use for this type of document and then hit 'change all' for that type of doc. Well that's the theory at least. I've found that this setting doesn't stick in this case. (I've never seen this not work).  It still opens with the new Numbers.
    I've tried removing Numbers, but Software Update keeps nagging that there is an update available jfor Numbers, and wants to reinstall it. They 'dumbed down' Software Update so that you can't remove updates you don't want to be bothered by. (I hate it that Apple continually removes features, then adds them back in a year or two!) So I'm stuck.
    Any one else have this happen? Any fixes?
    Thanks!

    Using Get Info to change all documents to open with Pages 4.3 doesn't work. The Mac OS will always default to the newest installed version & has for as long as I can remember. It will work on individual files, but that could be a lot of files to reset.
    This is what worked for me. After I installed the new iWork updates I created a folder on an external drive & named it "Applications." I then moved the new iWork apps to this folder & renamed the applications Keynote 6, Pages 5 & Numbers 3. I have icons for two versions of Pages & Numbers (I rarely use Keynote) in my Dock. Even with two versions of Pages & Numbers running, double-clicking an existing file opens in Pages 4.3 or Numbers 2.3. This should also keep the Mac App Store from nagging you to update.
    Since the last update I've used the solution Peter Breis posted (4th post in that thread) in iWork Tips 'n' Tricks with a little "tweak."
    Making Numbers '09 the default whilst keeping Pages 5
    1. Move any new iWork apps in another clearly labelled folder (I created a new folder in Applications & named it iWork 13)
    2. Menu > Apple > System Preferences > Spotlight > Privacy > drag the above folder into the list
    2) Move the new iWork folder into the trash (temporarily)
    3) Select any Numbers file in Finder > Menu > Info (cmd+i) > Open with: > Pages '09 > Change all
    4) Re the new iWork folder from the trash (right-click > Put back)
    Pages 5 should no longer appear as a default App, and you won't have to keep a copy in a separate drive or dmg.
    IMPORTANT: Make a note of where and how Pages was installed for the next App Store update and temporarily move it back there before putting it away again in the folder concealed from Spotlight.

  • My iPod 5 shut down and hasn't turned back on (this isn't the first time it happened) I've read to put it in recovery mode but my home button doesn't work, how can I fix it?

    ipod 5, had it for about 2-3 years, constantly shuts downs for about 12 hours but this time it hasn't turned on for a whole day, and my home button doesn't work which occurred a long time ago.

    Try this previous discussion:
    Turn on without Home/Power Button

  • My program work's good in a PC but in a laptop doesn't work.

    MY program doesn't work in a laptop but in PC work very good

    A lot more information is required. When you say it doesn't work on the laptop, do you mean it runs slow or are there error messages generated? If there are errors, what are they? Is there any hardware being used? Are there differences in OS or memory between the pc and laptop? Is this an executable you're running?

  • Mac os x 10.6.8 disc one is installed but the 2nd disc doesn't work and seems somewhat scratched, the computer is still asking to insert disc 2 which i inserted but doesn't work!!! h

    Hi,
    i have a 2008 macbook pro, i was using mac os x 10.5, but decided to install mac os x 10.6.8, the 1st disc was installed correctly but the 2nd one
    is not working and seems scratched, because i inserted it but the computer was still asking me to insert the disc 2,  now i don't know what to do!!!
    may i shut down the computer or what?? please, HELP!!!!

    You can contact Apple Support and request a new set of disks, have your serial number handy, and if possible, they will send them to you for a nominal fee. (usually about $20.00)
    800-692-7753 Technical Support.
    You can get get your serial number from the back of your machine, or if possible, click on the Apple logo in the menu bar, About this Mac>more info, it should be on the first window that comes up. Many Macs disks are build specific so this is important.
    You can GENTLY try polishing out the scratch with a micro fiber cloth, or a very SOFT cloth, moving from the center out, very gently, then rinse and DRY THOROUGHLY,and give it another try, if no joy try the tech support.
    Hope this helps

  • I'm trying to set up a new feed reader (Brief) using Live Bookmarks but the suscribe button doesn't work. Anyone got a solution to this?

    I'm currently using Google reader for my feeds but Google is discontinuing it in July. So I need a new feed reader option. I am trying to set up the Brief add-on as my reader, using Live Bookmarks but when I attempt to subscribe to a feed, the subscribe button doesn't work.

    Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies do the following:
    #Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
    Did this fix your problems? Please report back to us!
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''

  • Just upgraded to 6.1 but my iTunes password doesn't work for my restore

    Just backed up my iPhone4 in iTunes, transferred purchased items to my iTunes library, and then updated the IOS to 6.1.  Now iTunes is giving me the option to restore from my backup, but it wants a password, and my iTunes password doesn't work!  I was never asked for a new password for by backup so I'm very surprised my iTunes password doesn't work.  I just logged into this forum with my iTunes password so I know it is still active.  Anyone have any ideas of what I should do next?  Thanks!

    I was wrong --- turns out I did create a password long ago for my first backup, different than my iTunes password, and fortunately I was able to remember it.  The restore worked fine once I gave it the password that it wanted. 

Maybe you are looking for

  • My iMac will not boot up.  it brings up a black screen with a cursor

    all of a sudden my imac will not boot up.  it brings up the grey page with the apple, then instead of going to the login, it goes to a blank black page.  The cursor moves with the mouse, but that is it

  • Sky hub and TC

    I used to use my TC attached to my modem from my ISP via Ethernet. I've now changed ISP to Sky (in UK), and now have a Sky hub SR102 (black box), this hub now does the wireless network and modem job. I think you can run either the Sky hub or TC in br

  • Add "resume download" function to my program

    Hi,my program is more complete now,and now I want to add the resume download function,I've search on net,and here but I haven't found nothing.I use my own protocol(see this to read the source: http://forum.java.sun.com/thread.jspa?threadID=5220335 ).

  • Make synchronous calls using JCo

    Hi everyone, I have done an integration project using JCo talking to the SAP system. The task would be creating a document (BAPI_DOCUMENT_CREATE2), and then checking in the content (BAPI_DOCUMENT_CHANGE2). I found sometimes the document created in st

  • IMac not getting very far into boot sequence.

    Hi, I can no longer get OSX to boot up much further than after initial screen where it makes the noise, and has the spinning icon, after that if moves to a blue screen, light blue, occasionaly the hard drive will make a noise as if it's accessing it,