开发者

how to open Filedialog in desired directory

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜