我意识到使用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