Click here to Skip to main content
15,906,569 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
l have 2 JTrees A and B, inside a frame. l fill tree A with computers names gotten through the active directory. When l select a PC in tree A(e.g, lemme say l select PC-1), l get all the folders in the PC-1 and use the folders to fill(create) tree B. It happens that if l select another PC(PC-2), the contents of tree B (that was showing before from PC-1) doesn't clear for the contents of the PC-2 to show(fill) on tree B.

what l want to achieve is that, when l select PC-1 in tree A, it will fill tree B, and when l select PC-2, the tree B contents(by PC-1) will clear for the contents of PC-2 to paint the tree B.

l have tried three different approaches like reloading, repainting, setting to null, none works.

l need a help.

What I have tried:

Java
DefaultTreeModel defMod1 = (DefaultTreeModel)jTree1.getModel();                 
defMod1.reload();
jTree1.repaint();
defMod1.setRoot(null);
Posted
Updated 25-Aug-17 22:36pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900