I have a file abc.csv
which is my bom (bill of material) file. I need to use that file to make a Tree view using Jtree. My file has data like this:
PARENT_NAME QUANTITY COMPONENT_NAME
HOLDER 1 BODY
HOLDER 1 PTRY_GASKET
HOLDER 1 PTRY
HOLDER 1 DISC
HOLDER 1 GUIDE_SET
HOLDER 1 STEM
HOLDER 1 COV_FLG
HOLDER 1 FOLLOW_FLG
.... other entries here
Here is my full file I have in gist since it's a very big file so I cannot paste it here.
Since I recently started working with JTree so I am slightly confuse how this will work. I have got below code so far:
public static void main(String[] args) {
JFrame frame = new JFrame("FileTree");
frame.setForeground(Color.black);
frame.setBackground(Color.lightGray);
Container cp = frame.getContentPane();
if (args.length == 0) {
cp.add(new FileTree(new File("abc.csv")));
}
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public FileTree(File dir) {
setLayout(new BorderLayout());
// Now how do I make a tree list with all the nodes, and make it a JTree from my bom
}