1

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.

jmj
  • 237,923
  • 42
  • 401
  • 438
user542719
  • 307
  • 1
  • 9
  • 21

1 Answers1

5

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.
Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268