开发者

how to open Filedialog in desired directory

开发者 https://www.devze.com 2023-02-05 11:07 出处:网络
I have two buttons both open filedialog what i want both button should always open 开发者_开发问答their related directories in filedialogwhen they press.In my case filedialog keep the last open direct

I have two buttons both open filedialog what i want both button should always open 开发者_开发问答their related directories in filedialog when they press.In my case filedialog keep the last open directory which i don't want.


You didn't name the used framework, but assuming, it's Swing, JFileChooser has some constructors that allow to set the initial path:

JFileChooser(File currentDirectory)
      Constructs a JFileChooser using the given File as the path.

For FileDialog from the AWT framework, use a setter to set the directory before displaying the dialog

setDirectory(String dir)
      Sets the directory of this file dialog window to be the specified directory.
0

精彩评论

暂无评论...
验证码 换一张
取 消