我有两个按钮都打开了filedialog我想要的两个按钮应该总是在他们按下时在filedialog中打开他们的相关目录。在我的情况下,filedialog保留最后一个我不想要的打开目录。
答案 0 :(得分:5)
你没有命名使用过的框架,但假设是Swing,JFileChooser
有一些允许设置初始路径的构造函数:
JFileChooser(File currentDirectory)
Constructs a JFileChooser using the given File as the path.
对于AWT框架中的FileDialog
,使用setter在显示对话框之前设置目录
setDirectory(String dir)
Sets the directory of this file dialog window to be the specified directory.