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.
精彩评论