簡體   English   中英

將 Java Swing 中的文件樹組件替換為另一個

[英]Replacing a file tree component in Java Swing to another

我需要幫助使用 java swing 將 SB_Administrator.java 中 GUI 左側的虛擬文件樹替換為 FileTree.java 的更高級的 java 樹。

我目前在 Eclipse 中使用 windowBuilder。

在此先感謝您的幫助

SB_Administrator.java


        // Get the root node of the tree
        DefaultMutableTreeNode rootSess = (DefaultMutableTreeNode) tree.getModel().getRoot();
        //rootSess.setUserObject(sess);     // remember the Session in it


        splitPane.setLeftComponent(tree);

        JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
        splitPane.setRightComponent(tabbedPane);
    }

}

文件樹

………………………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………………… ……………………………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………………………………

  1. 創建一個新的FileTree對象
  2. 給出一個File對象作為參數(eq new File("root_path")
  3. 用新樹splitPane.setLeftComponent(fileTree)替換舊樹splitPane.setLeftComponent(tree) splitPane.setLeftComponent(fileTree)
FileTree fileTree = new FileTree(new File("./"));
splitPane.setLeftComponent(fileTree);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM