0

I want a path of "Turbo C++" folder when I click on approve but whenever i approves it gives me path of "c:" because Turbo C++ folder is in "C:". How to get full path of folder.

JFilechooser

  • http://stackoverflow.com/questions/14589386/how-to-save-file-using-jfilechooser-in-java see this link – Benjamin Feb 17 '16 at 13:41

1 Answers1

0

Try This :

You Must be select File From JFileChooser. They doen't visible if you select Directoy only JFileChooser Doc Sets the selected file. If the file's parent directory is not the current directory, changes the current directory to be the file's parent directory. using a getAbsolutePath shows path of Folder.

    File selectedFile=JFileChooser_object.getSelectedFile();
    System.out.println("selected File path"+selectedFile.getAbsolutePath());



      public void mouseClicked(java.awt.event.MouseEvent e) {
      if (jButton.isEnabled())
      {
      JFileChooser chooser = new JFileChooser();
      chooser.setCurrentDirectory(new File("."));
      chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      chooser.showOpenDialog(null);
      File selectedPfile = chooser.getSelectedFile();
      jTextField1.setText(selectedPfile.getAbsolutePath());
     }
    }
Benjamin
  • 2,257
  • 1
  • 15
  • 24
  • but i don't want to access any file instead I have to save a file and that's why i need current Directory not selected file's path. – Vishal Raut Feb 17 '16 at 13:37