Re: Children.getNodes() gives copy of nodes
Tim Boudreau <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <CA+qecRM+omrR64htbBQg_nono7Qs6zweB0mHYkYrsKxL3Q=XsQ@mail.gmail.com> |
There are no "original" items. Children are created on demand. If nothing is referencing them, they are garbage collected. So you could cache the nodes somewhere, which would force them to remain in memory and be reused, BUT... Child nodes are really supposed to be a view over some other objects (which can have whatever lifecycle you choose) that are your actual data model - and that's what you should be changing the state on. So consider other ways to solve the problem and you'll probably wind up with a better architecture. -Tim On Mon, Sep 12, 2016 at 7:17 AM, rsobies <[email protected]> wrote: > hello > i have a problem with BeanTreeView and Children class > when my applicatoion is started, main nodes are collapsed and if i call > node.getChildren().getNodes() i get copy of nodes. if i try to change > their state it is not permanent. i am sure becouse there are logs from > overriden finalize method of destroyed nodes by gc. > but if the user expand a node first (subnodes are created and never > destroyed-correct) and then i call node.getChildren().getNodes() (no nodes > are recreated) i get original nodes and can modify their states permanently. > > is there way to get orginal items? > > best regards > radek > > > > > -- http://timboudreau.com