How to get the selected file extension from FileChooser in JavaFX2?

I understand the use of Swing and JFileChooser, this is a simple use case of getFileFilter , but I cannot find any similar parameters in JavaFX2 for this FileChooser.

The problem is that when saving the file, if the file extension is not explicitly entered by the user, I want the file to be added with the current selected file extension in the FileChooser drop-down list.

In the following image, I would like to save this file as text.xml, for example.

+4
source share
1 answer

This problem has already been mentioned in jaavfx-jira.You Maybe the trck status here failed to save the file name with the selected extension filter.

I will copy the information here for quick reference:

Description: create a simple program to start FileChooser SaveDialog and add some expansion filters, for example: * .txt, * .java, .. Run the program when the save dialog appears, select * .txt from the filters and enter the file name without extension, then click Save. Note the file name to save, the extension “.txt” is not attached, and there seems to be no FileChooser method to get the selected filter. Not sure if this is an expected feature, but it is not convenient.

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

+2
source

All Articles