0
我試圖完成的是取一個預先定義的文件路徑,並在JTree裏面的文件路徑中顯示每個文件夾和文件。如何顯示JTree中文件夾的內容?
簡單;
Folder1
Folder2
Folder3a
->File3a
->File2a
->File2b
我有什麼到目前爲止是這樣的:
public class GUI extends JPanel {
public GUI() {
super(new GridLayout(1, 2, 20, 0));
setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (final Exception ignored) {
}
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setContentPane(this);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
我很想對如何進行一些指導。到目前爲止,所有的東西都是我經歷過的大量閱讀的彙編,我不確定如何完成我想要的東西。
如果我沿着這條路線走下去,那就會帶來更多的問題; 1)如何獲取根目錄下所有文件的路徑? –
查看@AndrewThompson的[File Browser GUI](http://codereview.stackexchange.com/questions/4446/file-browser-gui)獲取一些想法 –