简体   繁体   English

如何编写 Java 目录选择器?

[英]How can I write a Java directory chooser?

How can I write a directory chooser as like that:我怎样才能像这样编写目录选择器:

在此处输入图像描述

or:或者:在此处输入图像描述

at Java?在 Java?

PS 1: I am developing a desktop application and I use Swing at my application. PS 1:我正在开发一个桌面应用程序,我在我的应用程序中使用 Swing。

PS 2: I want to list just directories. PS 2:我只想列出目录。

You could use a TreeTable, here's a directory scanner using a treetable with a pretty decent tutorial: http://java.sun.com/products/jfc/tsc/articles/treetable1/您可以使用 TreeTable,这是一个使用树表的目录扫描器,其中包含相当不错的教程: http://java.sun.com/products/jfc/tsc/articles/treetable1/

Your second picture looks just like JFileChooser...您的第二张图片看起来就像 JFileChooser ...

      JFileChooser fileChooser = new JFileChooser(file);
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

If you want to change it's behavior just create a MyFileChooser class that extends JFileChooser.如果你想改变它的行为,只需创建一个扩展 JFileChooser 的 MyFileChooser class。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM