gpt4 book ai didi

java - JFileChooser 保存对话框建议文件名

转载 作者:行者123 更新时间:2023-12-01 09:02:40 24 4
gpt4 key购买 nike

Possible Duplicate:
JFileChooser.showSaveDialog(…) - how to set suggested file name

我已经看到这个问题被问了几次,但没有一个答案对我有任何帮助。我希望保存对话框使用 JFileChooser 建议像“myFile.txt”这样的文件名。

这是我所拥有的:

JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setCurrentDirectory(new File("C:\\"));
jFileChooser.showSaveDialog(null);

最佳答案

这样就可以了:

jFileChooser.setSelectedFile(new File(optionalPath + "myFile.txt"));

关于java - JFileChooser 保存对话框建议文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14002898/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com