Eu quero que minha JTree navegue pela pasta raiz ( C:\ ), como faço isso!?
Esta é a classe que estou trabalhando:
package Frames;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.GroupLayout;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTree;
import javax.swing.LayoutStyle;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import java.io.File;
import sun.management.FileSystem;
import sun.security.x509.Extension;
import com.swtdesigner.SwingResourceManager;
public class FramePrincipal extends JFrame {
private JTree tree;
private JList list;
String x = "C:";
public FramePrincipal() {
super();
setIconImage(SwingResourceManager.getImage(FramePrincipal.class, "/com/sun/java/swing/plaf/windows/icons/Computer.gif"));
setTitle("Controle de curriculo - CATHO");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JScrollPane scrollPane;
scrollPane = new JScrollPane();
list = new JList();
scrollPane.setViewportView(list);
JScrollPane scrollPane_1;
scrollPane_1 = new JScrollPane();
tree = new JTree();
scrollPane_1.setViewportView(tree);
final GroupLayout groupLayout = new GroupLayout((JComponent) getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
.addContainerGap())
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE)
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 300, GroupLayout.PREFERRED_SIZE))
.addContainerGap(39, Short.MAX_VALUE))
);
getContentPane().setLayout(groupLayout);
final JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
final JMenu arquivoMenu = new JMenu();
arquivoMenu.setText("Arquivo");
menuBar.add(arquivoMenu);
final JMenuItem newItemMenuItem = new JMenuItem();
newItemMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent arg0) {
dispose();
}
});
newItemMenuItem.setText("Sair");
arquivoMenu.add(newItemMenuItem);
pack();
//
}
}
Agradeço desde já!