简体   繁体   中英

How to get selected file extension from FileChooser in JavaFX2?

I realise using Swing and JFileChooser, this is a simple of case of using getFileFilter but I can't seem to find any similar options in JavaFX2 for it's FileChooser.

The problem is that when saving a file, if no file extension is explicitly typed by the user, I want the file to be appended with the current selected file extension in the FileChooser drop-down box.

In the image below, I would like this file to be saved as text.xml, for example.

This issue already reported in jaavfx-jira.You Can trck the status here unable to save file name with selected extension filter.

I am copy pasting info here for quick reference :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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