Hi All, How can i create a File Explorer using JTree in Swing so there is a tree representation for the localdisks? Left side showing the tree and right side showing the files of the selected folder in the tree. Expected behaviour is replication of winodws explorer behaviour.
You could make a JTree for the left and a JTextArea for the right component, both in JScrollPanes. A JFileChooser allows you to navigate the file system and select files and directories. If a directory is selected you can show its files in your tree. Use methods of the File class api to collect the files. You could make up a small data store class to store the URL for each file and return the file name in its toString method (which will be called by the treeNode for display). Use this class as a wrapper for each file and use it as the userObject in each DefaultMutableTreeNode for the tree.
When the user selects a node you can retrieve the wrapper from the node and get the file URL which you then use to read the file into the textArea.
subject: How to create a File Explorer using JTree