Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2005

Tip: Looking for answers? Try searching our database.

Jtree Reselect after reload

Thread view: 
jozeph78 - 15 Dec 2005 15:40 GMT
I'm running into a  problem reseelcting a newly inserted node into a
tree, performing a reload() and then finding the path to the node just
inserted.  Some changes to the database the Tree represents occur
(deleting a node creating new node in the parent's parent, then a node
in that node, then move all the children of the deleted node into the
new node. In order to make sure the user objects in the tree properly
reflect the changes to the database it is much safer for me to refresh
the whole tree which calls reload on the tree model.

Let me briefly describe my tree it looks like this....

Root
--Folder 1
------Group
----------Image
----------Image
----------Image
----------Image
--Folder 2
------Group
----------Image
----------Image
----------Image
----------Image

What I'm doing is changing an image to a folder, creating a new group
and moving the images into the new group so afterwards it looks like
this if I convert the 3rd image in folder 2...

Root
--Folder 1
------Group
----------Image
----------Image
----------Image
----------Image
--Folder 2
------Group
----------Image
----------Image
--Folder 3
------Group
----------Image

The problem is that after I reload the tree It seems to invalidate my
TreePath node.  Isn't there a way to grab the "Location" of folder2,
locate it,  and then select it's child after a reload?
Thomas Weidenfeller - 15 Dec 2005 15:54 GMT
> I'm running into a  problem reseelcting a newly inserted node into a
> tree, performing a reload()

Bzzzt, game over. Doing a reload() on a JTree is an almost 100% sure
indication that you got the event handling between the JTree and its
model wrong. Very wrong.

> In order to make sure the user objects in the tree properly
> reflect the changes to the database it is much safer for me to refresh
> the whole tree which calls reload on the tree model.

It's not saver, it is simply wrong.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

jozeph78 - 15 Dec 2005 16:22 GMT
True but I'm certainly not going to rewrite this 6000line class when my
company isn't a big fan of refactoring. Wrong or not, I can't change
their refreshTree method which calls reload.

I guess I'll have to do the tree node manipulation manually instead of
calling refreshTree. I think we do have some insert<Object>  for
inserting the object types as nodes into the tree. Hopefully it won't
be too painful.

Thanks for saving me a bunch of time trying to do something that's
otherwise impossible. I really appreciate it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.