How to add nodes to a Jtree by getting the information into a specific file
For example, in JList:
|
Code:
|
DefaultListModel workgroups;
workgroups = new DefaultListModel();
List<String> workgroupsList = new ArrayList<String>();
workgroupsList = ParserUtils.getWorkgroupList(ParserUtils.getConfigPath() + "\\.workgroup.properties");
if (!workgroupsList.isEmpty()){
for (String workgroup : workgroupsList){
workgroups.addElement(workgroup.toString().trim());
}
}
workgroupList = new JList(workgroups); //adds the list workgroups |
The output of this will be a JList displaying the list of workgroups per line. The list could be found in a file name "workgroup.properties"
Question is, is it possible to adapt this same method in JTree. The information per line will serve as one node in the tree. For example, I have 3 workgroups in the list, there will also be 3 nodes to be found in the tree.
Any suggestions?
THanks.