0
我需要在Panel
中嵌入JFileChooser
對話框。我只需要文件和文件夾視圖。如何禁用他人面板中包含的dialogBox
即(文件操作,文件的選擇和過濾器面板)從JFileChooser()
dialogBox
..如何從JFileChooser(JAVA Swing)禁用文件操作,文件選擇和過濾器面板?
謝謝
我需要在Panel
中嵌入JFileChooser
對話框。我只需要文件和文件夾視圖。如何禁用他人面板中包含的dialogBox
即(文件操作,文件的選擇和過濾器面板)從JFileChooser()
dialogBox
..如何從JFileChooser(JAVA Swing)禁用文件操作,文件選擇和過濾器面板?
謝謝
你可能要考慮使用JTree
顯示文件結構體。
將文件結構轉換爲TreeModel
的實現相當容易。
基本上我會先做一個叫做FileTreeModel
的班。
然後,您可以使用頂級目錄作爲模型的根目錄並從那裏開始。
然後,您只需將TreeModel
的JTree
設置爲您的FileTreeModel
。
爲FileTreeModel
代碼可能是這個樣子:
private File root;
public TreeModel(File root){
this.root = root;
}
public boolean isLeaf(Object node){
File f = (File) node;
return !f.isDirectory();
}
您需要實現該接口的其餘部分。但它非常簡單。
我已經能夠禁用打開/取消按鈕面板,但仍然存在其他問題。 FileSystemView view = null; JFileChooser jfc = new JFileChooser(); fc.setControlButtonsAreShown(false); – ranendra 2009-04-30 04:38:41