java - 如何在 JFileChooser 中仅列出硬盘驱动器?

标签 java swing jfilechooser

有没有办法在 JFileChooser 中仅列出根驱动器?我的意思是我需要防止在 JFilechooser 中列出光盘驱动器/可移动驱动器。我正在使用 java6。

提前致谢

更新

或者知道所选文件来自 CD/DVD 驱动器就可以了...可以以独立于平台的方式吗?

谢谢

最佳答案

By default, a file chooser displays all of the files and directories that it detects, except for hidden files. A program can apply one or more file filters to a file chooser so that the chooser shows only some files. The file chooser calls the filter's accept method for each file to determine whether it should be displayed. A file filter accepts or rejects a file based on criteria such as file type, size, ownership, and so on. Filters affect the list of files displayed by the file chooser. The user can enter the name of any file even if it is not displayed.

这里是链接How to Use File Choosers

关于java - 如何在 JFileChooser 中仅列出硬盘驱动器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19969387/

相关文章:

java - 区分 GZIP 和非 GZIP 格式不起作用

java - 如何列出 Java 属性对象中的所有值?

java - java中的多种原始类型

java - 远程 JVM 机器人调用

java - 如何使用 Swing 计时器

java - JFileChooser 和 "Details View"

java - 如何使 JFileChooser 默认为计算机 View 而不是我的文档

java - 如何从 Java Scanner 获取整数输入

java - JTextField 上的 TitledBorder

java - 从目录中过滤和选择文件