Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1627 > unrolled thread
| Started by | "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:34 +0000 |
| Last post | 2011-04-27 15:34 +0000 |
| Articles | 7 — 3 participants |
Back to article view | Back to comp.lang.java.gui
automatic refreshing of J "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: automatic refreshing "Qu0ll" <qu0ll@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: automatic refreshing "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: automatic refreshing "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: automatic refreshing "Qu0ll" <qu0ll@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: automatic refreshing "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: automatic refreshing "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
| From | "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | automatic refreshing of J |
| Message-ID | <464a7cdf$0$502$4c368faf@roadrunner.com> |
To: comp.lang.java.gui
Hello,
I'm having a hell of a time trying to get a JTree to automatically
refresh to show that a node has been moved from one parent node to another.
I'm using the following statement to move the node to the new parent:
model.getTreeModel().insertNodeInto(movedNode,
newParent,newParent.getChildCount());
I'm trying to implement cut/copy/paste functionality and I'm working to
get cut/paste functionality working first so in my paste method I test
for the original operation. If it was a "cut" then I do the following:
model.getTreeModel().removeNodeFromParent(movedNode);
However both of the statements above do not make the tree refresh
automatically to show the changes. I thought using the above were
supposed to do that? I tried the reload() method of the tree model and
of course when I do that the entire tree collapses and that isn't what I
want (I have a feeling hardly anyone finds that "feature" of the
reload() method useful).
Is reloading the tree the only way to make the change in the node's
location visible in the tree? If so, what the hell is the point of those
particular methods when I could just do, for an insertion,
newParent.add(movedNode) instead?
thanks
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Qu0ll" <qu0ll@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: automatic refreshing |
| Message-ID | <464a8503$0$9099$5a62ac22@per-qv1-newsreader-01.iinet.net.au> |
| In reply to | #1627 |
To: comp.lang.java.gui "Brandon McCombs" <none@none.com> wrote in message news:464a7cdf$0$502$4c368faf@roadrunner.com... > Hello, > > I'm having a hell of a time trying to get a JTree to automatically refresh > to show that a node has been moved from one parent node to another. > > I'm using the following statement to move the node to the new parent: > model.getTreeModel().insertNodeInto(movedNode, > newParent,newParent.getChildCount()); > > I'm trying to implement cut/copy/paste functionality and I'm working to > get cut/paste functionality working first so in my paste method I test for > the original operation. If it was a "cut" then I do the following: > model.getTreeModel().removeNodeFromParent(movedNode); > > However both of the statements above do not make the tree refresh > automatically to show the changes. I thought using the above were supposed > to do that? I tried the reload() method of the tree model and of course > when I do that the entire tree collapses and that isn't what I want (I > have a feeling hardly anyone finds that "feature" of the reload() method > useful). > > Is reloading the tree the only way to make the change in the node's > location visible in the tree? If so, what the hell is the point of those > particular methods when I could just do, for an insertion, > newParent.add(movedNode) instead? Are you notifying the tree that a new node has been inserted or removed? -- And loving it, -Q _________________________________________________ Qu0llSixFour@gmail.com (Replace the "SixFour" with numbers to email me) --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: automatic refreshing |
| Message-ID | <464a8980$0$15169$4c368faf@roadrunner.com> |
| In reply to | #1628 |
To: comp.lang.java.gui Qu0ll wrote: > "Brandon McCombs" <none@none.com> wrote in message > news:464a7cdf$0$502$4c368faf@roadrunner.com... >> Hello, >> >> I'm having a hell of a time trying to get a JTree to automatically >> refresh to show that a node has been moved from one parent node to >> another. >> >> I'm using the following statement to move the node to the new parent: >> model.getTreeModel().insertNodeInto(movedNode, >> newParent,newParent.getChildCount()); >> >> I'm trying to implement cut/copy/paste functionality and I'm working >> to get cut/paste functionality working first so in my paste method I >> test for the original operation. If it was a "cut" then I do the >> following: >> model.getTreeModel().removeNodeFromParent(movedNode); >> >> However both of the statements above do not make the tree refresh >> automatically to show the changes. I thought using the above were >> supposed to do that? I tried the reload() method of the tree model >> and of course when I do that the entire tree collapses and that isn't >> what I want (I have a feeling hardly anyone finds that "feature" of >> the reload() method useful). >> >> Is reloading the tree the only way to make the change in the node's >> location visible in the tree? If so, what the hell is the point of >> those particular methods when I could just do, for an insertion, >> newParent.add(movedNode) instead? > > > Are you notifying the tree that a new node has been inserted or removed? > Well, I can't say I am doing so explicitly. But I thought that was the point of using the methods I mentioned above. The JavaDoc for the insertNotInto() method states the following that lead me to believe that: This will then message nodesWereInserted to create the appropriate event. This is the preferred way to add children as it will create the appropriate event. Isn't the "appropriate event" the mechanism that will notify the tree that a new node has been inserted? If not, what method do I need to call to notify the tree? thanks --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: automatic refreshing |
| Message-ID | <464a8a7a$0$8975$4c368faf@roadrunner.com> |
| In reply to | #1628 |
To: comp.lang.java.gui Qu0ll wrote: > "Brandon McCombs" <none@none.com> wrote in message > news:464a7cdf$0$502$4c368faf@roadrunner.com... >> Hello, >> >> I'm having a hell of a time trying to get a JTree to automatically >> refresh to show that a node has been moved from one parent node to >> another. >> >> I'm using the following statement to move the node to the new parent: >> model.getTreeModel().insertNodeInto(movedNode, >> newParent,newParent.getChildCount()); >> >> I'm trying to implement cut/copy/paste functionality and I'm working >> to get cut/paste functionality working first so in my paste method I >> test for the original operation. If it was a "cut" then I do the >> following: >> model.getTreeModel().removeNodeFromParent(movedNode); >> >> However both of the statements above do not make the tree refresh >> automatically to show the changes. I thought using the above were >> supposed to do that? I tried the reload() method of the tree model >> and of course when I do that the entire tree collapses and that isn't >> what I want (I have a feeling hardly anyone finds that "feature" of >> the reload() method useful). >> >> Is reloading the tree the only way to make the change in the node's >> location visible in the tree? If so, what the hell is the point of >> those particular methods when I could just do, for an insertion, >> newParent.add(movedNode) instead? > > > Are you notifying the tree that a new node has been inserted or removed? > I forgot to mention that my tree model is in fact the DefaultTreeModel so that's why I thought the notifications should happen automatically as long as I used the methods above. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Qu0ll" <qu0ll@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: automatic refreshing |
| Message-ID | <464a8e54$0$9094$5a62ac22@per-qv1-newsreader-01.iinet.net.au> |
| In reply to | #1631 |
To: comp.lang.java.gui "Brandon McCombs" <none@none.com> wrote in message news:464a8a7a$0$8975$4c368faf@roadrunner.com... > Qu0ll wrote: >> "Brandon McCombs" <none@none.com> wrote in message >> news:464a7cdf$0$502$4c368faf@roadrunner.com... >>> Hello, >>> >>> I'm having a hell of a time trying to get a JTree to automatically >>> refresh to show that a node has been moved from one parent node to >>> another. >>> >>> I'm using the following statement to move the node to the new parent: >>> model.getTreeModel().insertNodeInto(movedNode, >>> newParent,newParent.getChildCount()); >>> >>> I'm trying to implement cut/copy/paste functionality and I'm working to >>> get cut/paste functionality working first so in my paste method I test >>> for the original operation. If it was a "cut" then I do the following: >>> model.getTreeModel().removeNodeFromParent(movedNode); >>> >>> However both of the statements above do not make the tree refresh >>> automatically to show the changes. I thought using the above were >>> supposed to do that? I tried the reload() method of the tree model and >>> of course when I do that the entire tree collapses and that isn't what I >>> want (I have a feeling hardly anyone finds that "feature" of the >>> reload() method useful). >>> >>> Is reloading the tree the only way to make the change in the node's >>> location visible in the tree? If so, what the hell is the point of those >>> particular methods when I could just do, for an insertion, >>> newParent.add(movedNode) instead? >> >> >> Are you notifying the tree that a new node has been inserted or removed? >> > > I forgot to mention that my tree model is in fact the DefaultTreeModel so > that's why I thought the notifications should happen automatically as long > as I used the methods above. I agree with you on the JavaDoc point but I have only ever used DefaultMutableTreeNode#add() and #remove() and then manually notifying the tree. You may wish to try this just to see if it's related to some other problem. Also, posting a SSCCE could help. -- And loving it, -Q _________________________________________________ Qu0llSixFour@gmail.com (Replace the "SixFour" with numbers to email me) --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: automatic refreshing |
| Message-ID | <464a9d5b$0$1344$4c368faf@roadrunner.com> |
| In reply to | #1632 |
To: comp.lang.java.gui Qu0ll wrote: > "Brandon McCombs" <none@none.com> wrote in message > news:464a8a7a$0$8975$4c368faf@roadrunner.com... >> Qu0ll wrote: >>> "Brandon McCombs" <none@none.com> wrote in message >>> news:464a7cdf$0$502$4c368faf@roadrunner.com... >>>> Hello, >>>> >>>> I'm having a hell of a time trying to get a JTree to automatically >>>> refresh to show that a node has been moved from one parent node to >>>> another. >>>> >>>> I'm using the following statement to move the node to the new parent: >>>> model.getTreeModel().insertNodeInto(movedNode, >>>> newParent,newParent.getChildCount()); >>>> >>>> I'm trying to implement cut/copy/paste functionality and I'm working >>>> to get cut/paste functionality working first so in my paste method I >>>> test for the original operation. If it was a "cut" then I do the >>>> following: >>>> model.getTreeModel().removeNodeFromParent(movedNode); >>>> >>>> However both of the statements above do not make the tree refresh >>>> automatically to show the changes. I thought using the above were >>>> supposed to do that? I tried the reload() method of the tree model >>>> and of course when I do that the entire tree collapses and that >>>> isn't what I want (I have a feeling hardly anyone finds that >>>> "feature" of the reload() method useful). >>>> >>>> Is reloading the tree the only way to make the change in the node's >>>> location visible in the tree? If so, what the hell is the point of >>>> those particular methods when I could just do, for an insertion, >>>> newParent.add(movedNode) instead? >>> >>> >>> Are you notifying the tree that a new node has been inserted or removed? >>> >> >> I forgot to mention that my tree model is in fact the DefaultTreeModel >> so that's why I thought the notifications should happen automatically >> as long as I used the methods above. > > I agree with you on the JavaDoc point but I have only ever used > DefaultMutableTreeNode#add() and #remove() and then manually notifying > the tree. notifying by doing what though? You've mentioned that twice w/o actually saying how you do it. You may wish to try this just to see if it's related to some > other problem. Also, posting a SSCCE could help. > I was already adding nodes using add/remove methods of the parent nodes and it wasn't working very well, at least for this particular feature that I was trying to add (cut/copy/paste), because of the way that JNDI sends out search requests. My method of add/remove methods for the rest of my program was and is working just fine. If I send out a search request to fill in the data of the tree where the node was removed and another search request (against my backend data source) to update the tree where the node was moved to then I get all sorts of weird things. The simplest way to put it is that the new location is updated properly but the old location isn't modified at all so the node looks like it is in 2 different locations at the same time. And *that* issue is due to how JNDI sends search requests to a server. Even with 2 different threads I only get back results on the 2nd search that I spawn which is why the refresh of the location where the node came from doesn't work at all. I thought if I go back to simplifying my code to make the JTree update itself then I wouldn't even have to go back to my data source, at least for refreshing the node that had one of its children removed. Simply removing the node from its source in the JTree for a cut operation would be sufficient and for where it gets pasted I could maybe get away with just modifying the JTree in that case too...but again, when I changed the code to make the JTree update itself it isn't working. Instead of wasting time trying to create an SSCCE I'll just keep working on my own. Trying to separate out my code into a separate program is not very productive in my opinion. If someone can at least say that the methods I've already mentioned are supposed to work the way the JavaDoc says then I know I'm at least on the right track and that it is with my code. Otherwise I know that the JavaDoc is wrong and I will have more work to do as a result. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: automatic refreshing |
| Message-ID | <do0n43tggp9kqf9bhe5kn93ln64d55rvrv@4ax.com> |
| In reply to | #1627 |
To: comp.lang.java.gui On Tue, 15 May 2007 23:38:52 -0400, Brandon McCombs <none@none.com> wrote, quoted or indirectly quoted someone who said : >However both of the statements above do not make the tree refresh >automatically to show the changes. I thought using the above were >supposed to do that? Keep in mind if you keep the Swing thread busy, it can never get around to updating the screen. Normally you do all your calculation on one thread and indirectly manipulate the main thread with SwingUtilities.invokeLater -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web