Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JFileChooser Question

Options
  • 11-04-2005 4:40pm
    #1
    Closed Accounts Posts: 43


    Does anyone know the best way to create a new folder using the JFileChooser.I have it set to look at directories only but Im trying to get it to create a folder when I click on the "open" button. Im lost at the moment and any help along those lines would be a help.


Comments

  • Registered Users Posts: 261 ✭✭HaVoC


    You probable should use showSaveDialog() as your not opening a file. Then use code like the following to create the new directory in the directory that the user
    has selected.
     if (returnVal == JFileChooser.APPROVE_OPTION)
     {
           File  dirRoot = fc.getSelectedFile();
           File  newDir = new    File(dirRoot.getPath()+System.getProperty("file.separator")+urNewDirectoryAsaString);                               
           newDir.createNewFile();
    }
    


Advertisement