使用不存在的目录初始化 JFileChooser
在我们的安装程序中,我想让用户能够使用安装目录,显然该目录还不存在。我希望当按下浏览按钮时,将打开一个JFileChooser对话框,并将使用当前选择的目录进行初始化。但是,setCurrentDirectory 仅适用于现有目录,而 setSelectedFile 似乎仅在不像我一样使用 DIRECTORIES_ONLY 时才适用。
有什么办法解决这个问题吗?
谢谢,
裂片
In our installation program I want to enable users to use install directory which, obviously, does not exist yet. I want that when the Browse button is pressed, a JFileChooser dialog will be opened, and will be initialized with the currently selected directory. However, setCurrentDirectory only works with existing directories, and setSelectedFile only seems to work when not working with DIRECTORIES_ONLY like I do.
Is there any way around this?
Thanks,
splintor
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我找到的(部分)解决方案。这对我来说已经足够好了:
This is the (partial) solution I found. It is good enough for me: