title: Displaying all the drives in the system in JTree
body: <p>Here's my code i am unable to display all the drive's in my current system in a jtree, all it returns is some random java file, am a beginner and do not have much idea about how it is done, awaiting help..</p>
  
  <pre><code>import java.awt.GridLayout;
  import java.io.File;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.JTree;
  import javax.swing.tree.DefaultMutableTreeNode;
  import javax.swing.tree.TreeSelectionModel;
  
  
  public class JTreeLits extends JPanel
  {
   JTree tree;
   public JTreeLits()
   {
          super(new GridLayout(1,0));
          DefaultMutableTreeNode rooter = new DefaultMutableTreeNode("FileSystem");
          DefaultMutableTreeNode parent;
          File [] roots = File.listRoots();
          parent = new DefaultMutableTreeNode(roots);
          rooter.add(parent);
  
          tree = new JTree(rooter);
          tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
          add(tree);
   }
   private static void createAndShowGUI()
   {
          JFrame frame = new JFrame("TreeDemo");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add(new JTreeLits());
          frame.pack();
          frame.setVisible(true);
          frame.setSize(250,400);
   }
   public static void main(String[] args)
   {
      createAndShowGUI();
   }
  }  
  </code></pre>