0

I dont know much about java. I wrote this code in JTree but when I run the program JTree just shows the last fList. Is there anything tha I can add to the code so that JTree display all of them? JTreeCode is another class in the same package.

File fList[] = File.listRoots();
for(int i = 0; i  < fList.length; i++)
{
    jTree1.setModel(new JTreeCode(fList[i]));
}
mKorbel
  • 109,525
  • 20
  • 134
  • 319
Kiki
  • 75
  • 1
  • 1
  • 7

1 Answers1

1

JTree implements a Model/View pattern. In this pattern, you build the entire model first and then you assign it to the tree only once. Multiple assigns of the Model result, as you have seen, in applying only the last one.

Jorge_B
  • 9,712
  • 2
  • 17
  • 22