[英]JavaFX FileChooser new file
Is it possible to use the JavaFX File Chooser (or a similar alternative) to create new files? 是否可以使用JavaFX文件选择器(或类似的替代方案)来创建新文件?
Entering the name of a non-existent file works on Linux (Ubuntu to be exact) but on Windows the file chooser does not allow that. 输入不存在的文件的名称在Linux上运行(确切地说是Ubuntu),但在Windows上,文件选择器不允许这样做。
Yes that should be possible, you just need to know the right function to call. 是的,应该是可能的,你只需要知道正确的呼叫功能。 The API for
FileChooser
details them in its opening paragraph here . 对于API
FileChooser
详细介绍它们在其开篇段落这里 。
A FileChooser can be used to invoke file open dialogs for selecting single file (showOpenDialog), file open dialogs for selecting multiple files (showOpenMultipleDialog) and file save dialogs (showSaveDialog).
FileChooser可用于调用文件打开对话框以选择单个文件(showOpenDialog),文件打开对话框用于选择多个文件(showOpenMultipleDialog)和文件保存对话框(showSaveDialog)。
USAGE 用法
Save file: 保存存档:
FileChooser fileChooser = new FileChooser();
File selectedFile = fileChooser.showSaveDialog(null);
Open one file: 打开一个文件:
FileChooser fileChooser = new FileChooser();
File selectedFile = fileChooser.showOpenDialog(null);
Open multiple files: 打开多个文件:
FileChooser fileChooser = new FileChooser();
List<File> files = fileChooser.showOpenMultipleDialog(null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.