public SelectableTree() { super("JTree Selections"); WindowUtilities.setNativeLookAndFeel(); addWindowListener(new ExitListener()); Container content = getContentPane(); String[] namesplitStrings = mainDir.toString().split("\\\\"); String filename = namesplitStrings[namesplitStrings.length - 1]; DefaultMutableTreeNode root = new DefaultMutableTreeNode(filename); addChildren(root, mainDir); tree = new JTree(root); tree.addTreeSelectionListener(this); content.add(new JScrollPane(tree), BorderLayout.CENTER); currentSelectionField = new JTextField("Current Selection: NONE"); content.add(currentSelectionField, BorderLayout.SOUTH); setSize(250, 275); setVisible(true); }