How to make output directory selection panel?

前端 未结 4 752
我寻月下人不归
我寻月下人不归 2021-01-22 15:36

Hi I am trying to make one pane that shows something like windows explorer in my computer. when user complete it\'s operations, and after that when he want to save edited image

4条回答
  •  失恋的感觉
    2021-01-22 16:19

    This can be handled with a JFileChooser, sorry if it's not the solution you're looking for

    Note: you say choose a directory but I assume you mean that they can name their file

    private File selectSaveFile() {
        JFileChooser fc = new JFileChooser();
        fc.setFileFilter(new FileNameExtensionFilter("File Type", "txt"));
        fc.setCurrentDirectory(new File(System.getProperty("user.home")));
        int returnVal = fc.showSaveDialog(frame);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            return fc.getSelectedFile();
        }
        //the user didn't click save if we are here
        return null;
    }
    

提交回复
热议问题