JTree: What do I do, when a leaf node isn't a leaf node?
Hi All,
I have a question about the JTree and leaf nodes.
My requirements are:
1) I have to have a tree which doesn't "fill" its contents at a certain level until the user expands a node
2) As a result of #1, leaf nodes must have a "+" sign in front of them until the user tries to expand them at least once (if they are then empty, the "+" is removed in favor of the normal leaf icon.. if they have data, the "+" is replaced with a "-" and the data is filled in)..
Currently, we have an implementation of this which adds a "dummy" node as a child of the leaf to force it to be a "non-leaf", until the user opens it, then the dummy object is removed and the real data (if any) is added..
It works, but I'm wondering if there is a simpler way.
Can anyone offer their opinion? Thanks a bunch.
Dave
What I do is to have some code that implements TreeWillExpandListener. What happens then is that when the user clicks on the doohickey to expand a node, my treeWillExpand(TreeExpansionEvent e) method is called. It examines the node that is about to expand and goes out to the database to load up its children. But to make this work, you have to have the doohickey available. This means that your nodes have to know whether their children have been loaded or not; this is the code I use to override the isLeaf() method for them:public boolean isLeaf() {
return (childrenLoaded ? super.isLeaf() : false);
}In this code "childrenLoaded" is a boolean instance variable that is initialized to false, then set to true via a property-setter method by the code that loads the node's children.
That's a rough outline of what I did. Good luck!
Similar Messages
-
What can i do when i purchase an app then after purchase the app fails to work. I deleted the app rebooted ipa then reinstated app. It still fails to work. I went to vendor support but when i go to send the info to them it comes up with unable to send msg due to page error. I am not happy. My child loved the app now it wont even open. Any help???
Try talking to iTunes support
http://www.apple.com/support/itunes/contact/ -
what do i do when my try to update my apps it tells me that i cannot conect to itunes store. Please help...
Try:
Can't connect to the iTunes Store -
What can i do when my older ipod wont let me even download free apps
What can i do when my older ipod touch won't let me download free apps?
- If you have a 2G iPod yu can update the iOd to as high as 4.2.1. There are many apps that will work with that but some require a 3G or higher or even a lter iOS.
- What happens when you try? Error messages? -
I have a Mac leopard. Did a recent recommended update. When it finished,I restarted then a window came up to enter Master Password. I don't know what it is and when I try to enter one, the window shakes so I am unable to use computer at all.
Please confirm exactly what Mac this is, and what 'recent update' you installed.
-
Crash report aplication what is that ? When shut the computer this Message appeared The application crash repórter Dont Let shut down the computer
Command-Option-Escape does the same as
Apple Menu > Force Quit...
It opens a floating box that lists current major Applications and their status (e.g., Not responding) and allows you to force quit any single Application or re-launch the Finder. -
What do you do when an app has been downloaded but won't open
What do you do when you download an app from the app store and it will not open once it is downloaded.
App Zapper is a paid app. AppCleaner does the same thing but is free;
http://www.freemacsoft.net/appcleaner -
What does it mean when I click on my wifi name and it show I'm on my wifi, but the network keeps thinking and the ipad says, Safari cannot open this page because it is not connected to the internet. ?
When you click on the WiFi network name, have you also provided the password for accessing the network? You should get a dialogue box asking you for the security information the first time you connect.
If you are not able to connect, you might want to go to Settings > General > Reset > Reset network settings.
Then go back to Settings > WiFi and select your network name again and make sure the security information is now entered correctly.
If you still cannot connect, power down the router, wait a few minutes, power up the router, with the iPad powered down the whole time, and after the router has had several minutes to stabilize power up the iPad. See if it now connects correctly. -
What does it mean when I get “there was an error in the App Store. Please try again later. (4)”?
Sign out of the Mac App Store via the Store menu
Quit the Mac App Store
Log out of your Mac OS X user account (from the Apple menu)
Log back in to your user account
Launch the Mac App Store, sign in, and try downloading again
You should be able to download any app trouble free now. If you still have problems, reboot your Mac. -
I am returning to Firefox after having used Safari on Mac for the past year. One thing I liked about Safari was that I could define what page gets loaded when I used the File Menu command to open a new Browser Window. I defined this as opening up with my Bookmarks Menu where I then was able to select the page I wanted to go to.
I have not been able to find a way to define this in Firefox and was surprised to see that "New Window" in Firefox opens all of tabs that I've defined as my Home Page.
Is there a way to manage this?This issue can be caused by an extension that isn't working properly.
Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
*Do not click the Reset button on the Safe mode start window or otherwise make changes.
*https://support.mozilla.org/kb/Safe+Mode
*https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes -
what do you do when you can't sync your ipod and it tells you that itunes is not compatible with your ipod?
Upgrade to the newest version of iTunes first to see if that helps.
B-rock -
What do you do when you can't read the code on a iTunes gift card?
What do you do when you can't read the code on a iTunes gift card? I tried taking it back to the store with my reciept, but they said I would have to contact Apple support. Am I out just out $25 dollars?
See this support article:
http://support.apple.com/kb/TS1292
Instructions are at the bottom of that article.
BTW, this forum is for questions about iTunes U, Apple's service for colleges and universities to post educational material in the iTunes Store. Normally you want to ask your questions in the general iTunes forums.
Regards. -
what do i do when i try to sync my ipod touch to itunes and it shows me an error message that the sync session failed to start?
Hello brainiac08
Typically that error occurs because of a backup issue. Check out the article below to resolve it.
iOS: Troubleshooting backup issues in iTunes
http://support.apple.com/kb/ts2529
Thanks for using Apple Support Communities.
Regards,
-Norm G. -
What do I do when I get the message my printer is not connected when I want to print wirelessly.? HP Officejet Pro 8500A e-All-in-One. I have a macintosh computer using snow leopard. I have used the printer for 6 months. Nothing has changed. I shut off the printer and turned it on. The internet is working altough I will turn it off and on. What do I do next? Thank you.
The easiest and fastest thing for you is to reset the printer to its defaults and then just install the printer again following the instructions in the manual when you received it. If you don't have these you will find this on the HP web site.
Say thanks by clicking the Kudos Thumbs Up to the right in the post.
If my post resolved your problem, please mark it as an Accepted Solution ...
I worked for HP but now I'm retired! -
Hello,
Do you know what I can do when my Iphone is blocked with the apple appearing ?
I cannot enter into the phone and I don't know what to do ?
Thank you for your help
AMGSOBasics from the manual are restart, reset, and restore.
Have you tried these?
Maybe you are looking for
-
I JUST CAN'T BELIEVE IT !
I have posted a question about using an external bootable drive on this forum. One answer was coming at the time I called Apple Care for which I paid to go with my IMAC. After spending a LONG time dealing with an incompetent person acting as a filter
-
How to change 'z' key into 'A' key with key blinding?
How to change 'z' key into 'A' key? Although txt.setText("A") can set the text field with 'a', but it is not original input from keyboard because it cant trigger the key listener. It is possible to perform key pressing more than a key in same time? E
-
Content protection is enabled, how do I undo this?
-
Alternative for Continue Statement in 10g
Best way to write below code in Oracle 10g (as continue does not exist) BEGIN FOR i IN 1..10 LOOP Dbms_Output.put_line(i); CONTINUE WHEN i>5; CASE Dbms_Output.put_line(i); END LOOP;
-
After offer release, employee has to fill personal details through URL-E-recruitment
Dear All, Client is Indian, After Offer release through e-recruitment. HR want to send URL mail to selected candidate. Through this URL candidate has to fill all personal details(Family details, IT Declarations, Blood group etc.) How to store this da