java - 如何从 JavaFX2 中的 FileChooser 获取选定的文件扩展名?

标签 java user-interface javafx-2

我意识到使用 Swing 和 JFileChooser,这是使用 getFileFilter 的一个简单案例,但我似乎无法在 JavaFX2 中为它的 FileChooser 找到任何类似的选项。

问题是在保存文件时,如果用户没有明确输入文件扩展名,我希望文件在 FileChooser 下拉框中附加当前选择的文件扩展名。

例如,在下图中,我希望将此文件另存为 text.xml。

最佳答案

此问题已在 jaavfx-jira 中报告。您可以在此处查看状态 unable to save file name with selected extension filter.

我在这里复制粘贴信息以供快速引用:

Description : Create a simple program to launch a FileChooser SaveDialog, and add several extension filters, for example: *.txt, *.java, .. Run the program, when the save dialog is displayed, select *.txt from the filters, and type file name without extension, then click "Save". Observe the file name to save, the extension ".txt" is not attached, and it seems there is no method of FileChooser to get the selected filter extension. Not sure if it's an expected feature, but it's not convenient.

Type: Feature Status: Open Priority: Medium Resolution: Unresolved

关于java - 如何从 JavaFX2 中的 FileChooser 获取选定的文件扩展名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13818817/

相关文章:

java - 雅各布 : calling vb function in Excel file without invoking "Open" statement

java - 尽可能大地扩展 JPanel

.net - 如何确定 .Net DLL 是否用于 GUI 应用程序或 Web 服务?

JavaFX 中可拖动元素的 CSS

java - 如何添加奖金?

Java - HttpServer 不提供图像

user-interface - 如何在Flutter中使用扩展面板列表构建名片屏幕?

JavaFX 平铺/流程 Pane 动画

java - 强制 TableView 在后续添加时调整列的大小

java - 带有队列的 SimpleAsyncTaskExecutor