Hello,
I would like to know what is the best way to populate a tree gui which has the following
details:
My application should reflect a tree structre with about 8000 members but directly under
the root there are maximum 15 members.Its clear that each time a user open the
application he wont need to look at all the 8000 members and my question is how to build
the tree ? should I load all members and build the tree or load just the first level and
only if a user expand a member ,its children should be loaded ? and if the second way is
better ,how should I know if the members were already loaded ?
The second issue is how to do it (if there is any difference) : my application can get
the members details by quering some sql tables (the member details actually handled by
another application and are in some tables) or getting the info into the stack by using
this other application api.
My application should reflect a tree structre with about 8000 members but directly under
the root there are maximum 15 members.
correct why not, there I can't see any issues with performence or freeze, but see my next comment
Its clear that each time a user open the
application he wont need to look at all the 8000 members and my question is how to build
the tree ?
not that maybe useless, why loads bunch of data that takes long time
that required redirect that to the BackGround Task(s), just display some reduced number of Nodes, and on 1st. Scroll from Scrollpane you can loading next data from BackGround Task, but again reduced value,
should I load all members and build the tree or load just the first level and
only if a user expand a member ,its children should be loaded ? and if the second way is
better ,how should I know if the members were already loaded ?
see my previous comment,
The second issue is how to do it (if there is any difference) : my application can get
the members details by quering some sql tables (the member details actually handled by
another application and are in some tables) or getting the info into the stack by using
this other application api.
depends of specifications and your free time for that, but SQL Engine (and that reason why exist) is still faster that any (maybe best) managed output/input stream
thanks for the answer ,as i am not experienced with working with threads (did you mean that when you wrote working on background) it will help if you please send me more details on how to implement it or ofcourse if you have some code example or a link which describe the way to do it.
NormR1 ,your reply goal isnt clear : Did you answer the question (NO) , or you just wanted to disturb ? what is the additional value of what you sent ? the above question was asked also in another forum ,so what? isnt it accaptable to ask some people the same question ? when you try to find out something do you limit yourself just to 1 site and dont ask yourself if there are other sites ? I hope that other people who read this forum will answer the question and wont be affected by your bad attitude
Hi yinp.
Although there is nothing necessarily wrong with cross-posting, if you do so it is normal protocol to mention that fact at each site where you have duplicated your post. You will find that many people chose not to waste their time trying to answer a question that may have already been answered elsewhere. Norm was just correcting your omission for you.
Thanks for your remark, I accept it but I hope that Norm had the same thought since
as he didnt add anything , just copied the link in both forums! it could be
understanded as :"People, dont answer this question.It was already asked in other place" and the worst thing is that he wrote it also in the other forum , so to avoid it lets agree that if someone can answer the original question it will be nice if he can do it here
Did you try what was suggested in post#2 on the other forum?
What happened? Did it work or was there a problem?
I have a program that uses JTree to display a disk's file contents. I just ran it to display files on one of my drives.
There are over 100K files scanned into the tree.
Here is a screen shot:
The answer on the other forum was a link to a basic article which I read but I found it more as an explanation on how to build a tree which usually has a few members (like in the example which they wrote that has about 8 members) but my main question
is not how to build such a tree but how to do it when there are 8000 members so I didnt start to develop it as written there since I wanted to wait for clever answeres from people who have experience with it. if you say that you have a program with a tree that works well with a lot of members I will thank you if you can send me a the code example or some more detailed explanation which describes the way to
do it since the answer I got here (working on background) wasnt clear for me.
That's one approach, wait for someone else to write your code.
What have you tried so far? What happened when you tried to build a tree with 8K members? Are all those 8K members at the same level or are they nested under other members?
Well,I am not sure but maybe you know this approch very well and can tell us about it since you have experience with it but what is really obvious is that from your
first reply your attitude is very negative so I suggest that if you dont want to help ,just stay away and dont disturb.This forum is for other kind of people - I know that it might be difficult for you to understand but there are people who like to help and share their experience. For your arrogant question:
I understand that you are "angry" if i didnt start writing the code and think that i
am waiting for someone else to write it .This isnt my approach! But ,it is very
stupid (and maybe it is your approach) to start writing a code without making any
design before it , especially when there are open issues and I think that the way I
know isnt the best way to do it now which means that when I have a basic performance
question and if i didnt know how to start and thought that other (nice ,not you)
people can help it is everybody approach to share the question , read other
experienced people ideas and yes, if someone had already done something like this and
want to send ,there isnt a problem. Thats what this forum all about : helping people.
As I wrote in the first question : the first direct level under the root has maximum
15 members but from there it might divide unevenly to another 1 level or maybe 12 levels with total 8000 members. Any change of your attitude and sending some answers
will be kindly accepted.
I was curious about the examples at the link posted on the other site. I took one of them and added 8000+ items to the tree at more than one level, compiled it and executed it. No problems. It works.
I wonder why you have not tried doing that? Take the simple example and change it to your requirements and see what happens. The name of the example program was: TreeDemo.
Make a copy of that program, look at it, change it to what you want it to do.
Where have you shown any effort in solving your problem?
If you asked again this kind of questions ,it seems to be that you didnt understand
what i wrote even it was very simple .Try to read what I wrote after your rude
question ,starting from "I understand that you are "angry" if i didnt start
writing " . Dont you understand that it isnt a good approach to get a 15 members tree example and try to use it for 8000 ? why to start if you know in advance that
it isnt the way to do it ? didnt you hear about the word : "design" ? even if it is
working in your case it doesnt mean that this is the way. It is very stupid to load
8000 members if you have to show just a few of it. I repeat for you : I dont want to waste time and reply your questions about if and what i tried. This forum tries to help people so if you have something new (like mKorbel answered but i didnt
understand ow to implement it - mKorbel if you can explain more please do it) you can answer but if you try to waste time and not help ,dont answer my questions.
Hey yinp - cool it.
Norm is one of our most experienced and helpful contributors. He works in the way we all try to do here, which is to ask questions and provide hints so the OP can learn for themself. If you re-read his posts you will see that he's trying to lead you towards checking for yourself what kind of problem 8k members is. If you put your effort into a test program rather than criticising you will find that you are trying to solve a non-problem.
I can assure you that Norm knows exactly what he is talking about, and he is trying to help you to build your own understanding. So let's play nice please.
@yinp
in the fact that all of suggestion by NormR1 were two steps forward
here is more that I want to post here
1/ you always must to know where is your concrete Object
2/ ---//--- how many Object you are displayed in concrete time
3/ ---//--- how you are implemets next, last and available Actions/Events
4/ ---//--- how you are implemets userfriendly resctiction for next, last and available Actions/Events
5/ user can waiting for any accelerated action(s), but during this time you have to enjoy her/his somehow (including animations)
6/ all actions must be valid only for Object in the visible Rectangle, leave doing anything with/for unvisible, nothing cares about un-visible elements,
and I forgot to say something similair as @JamesCherrill with my respect ... NormR1
JamesCherrill and mKorbel ,thank you for your answers.I read it,and believe me it
isnt my issue to argue and I came here just to learn from other people programming
experience.James, you wrote that all what Norm tried to do is to tell me that it
isnt a problem to load 8k members,but if he thinks so he could just write it
simply (as you did very kindly in 4 words) and not start to criticise me. Let me
remind you that his first answer was just copying a link to another forum without
saing anything which might be interpretated as "dont help this one , he is using
another forum " and in the other answer he wasnt trying to help as you thin but started his criticising way and said that I dont want to write code but waiting for another people to write it for me.I am sure that you also think that it isnt a good
approach to take. more than that ,after I tried to explain that it isnt about lazy
guy but about making a good design in order to avoid problems he continued with his
rude way and asked questions like why didnt I tried the demo example and where is my effort. Well I tried to repeat again and again I dont think (and please correct me
if I wrong) that I should start writing before designing ,the right direction is :
ask people , learn from their experience and then write the code. Taking his
approach could lead bad or useless code. I prefer waiting and then writing and i really dont have to give him a report if and how much effort i put here. If someone wants to help he is welcome, if someone doesnt want at least he doesnt have to disturb. For the demo file issue : as i wrote even if he tried to do it and loaded
thousnads of members and it works I still really dont think that it should be like this. It isnt efficent and logical to do it like this when the user will expand just
a few of it wach time. I try to find some way to load it on demend and to know each time if this member was already loaded or it should be done.The first answer of mKorbel (load just on demend and in the background) sounds very logical but as I wrote I couldnt really understand how to implement it.
Final comment: I think your instincts re "efficient and logical" may be misleading you in this particular case. 8k is a small number on today's typical machine, with processor speed measured in GigaHz and memory in GigaBytes. Remember also that "load on demand" will carry its own overheads both in data structures, execution overheads, and code size, not to mention effort for coding debugging and maintenance. Clearly it's a trade-off, so before investing significant effort in the more complex solution you should be very sure that there is an actual problem with the simple solution.
ps: If you really want to try load on demand then you start by creating a class that implements TreeModel. In your implementations of getChildCount and getChild you need to keep track of whether the necessary info has been loaded, and load it if necessary. You will probably need some careful optimisation of the load code, as you may end up (eg) doing many small SQL select statements as opposed to one full-sized one.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.