Class FileDialoger


  • public final class FileDialoger
    extends Object
    Class implementing a file open dialogue
    • Method Detail

      • promptToOpenFile

        public static JFileChooser promptToOpenFile()
        Prompts the user to choose a file from their filesystems for our own devious uses. This method maintains the last directory the user visited before dismissing the dialog. This does NOT imply they actually chose a file from that directory, only that they closed the dialog there. It is the caller's responsibility to check to see if the selected file is non-null.
        Returns:
        the JFileChooser that interacted with the user, after they are finished using it - null if no file was chosen
      • promptToOpenFile

        public static JFileChooser promptToOpenFile​(String existingFileName)
        Prompts the user to choose a file from their filesystems for our own devious uses. This method maintains the last directory the user visited before dismissing the dialog. This does NOT imply they actually chose a file from that directory, only that they closed the dialog there. It is the caller's responsibility to check to see if the selected file is non-null.
        Parameters:
        existingFileName - The name of a file with path. If the filename points to an existing file, the directory in which it lies, will be used as the starting point for the returned JFileChooser.
        Returns:
        the JFileChooser that interacted with the user, after they are finished using it - null if no file was chosen
      • promptToOpenFile

        public static JFileChooser promptToOpenFile​(String[] exts)
        Prompts the user to choose a file from their filesystems for our own devious uses. This method maintains the last directory the user visited before dismissing the dialog. This does NOT imply they actually chose a file from that directory, only that they closed the dialog there. It is the caller's responsibility to check to see if the selected file is non-null.
        Parameters:
        exts - The list of allowed file extensions. If empty, any file extension is allowed
        Returns:
        the JFileChooser that interacted with the user, after they are finished using it - null if no file was chosen
      • promptToOpenFile

        public static JFileChooser promptToOpenFile​(String[] exts,
                                                    String existingFileName)
        Prompts the user to choose a file from their filesystems for our own devious uses. This method maintains the last directory the user visited before dismissing the dialog. This does NOT imply they actually chose a file from that directory, only that they closed the dialog there. It is the caller's responsibility to check to see if the selected file is non-null.
        Parameters:
        exts - The list of allowed file extensions. If empty, any file extension is allowed
        existingFileName - The name of a file with path. If the filename points to an existing file, the directory in which it lies, will be used as the starting point for the returned JFileChooser.
        Returns:
        the JFileChooser that interacted with the user, after they are finished using it - null if no file was chosen
      • promptToSaveFile

        public static JFileChooser promptToSaveFile​(String filename)
        Prompts the user to choose a file from their filesystems for our own devious uses. This method maintains the last directory the user visited before dismissing the dialog. This does NOT imply they actually chose a file from that directory, only that they closed the dialog there. It is the caller's responsibility to check to see if the selected file is non-null.
        Parameters:
        filename - The name of a file with path. If the filename points to an existing file, the directory in which it lies, will be used as the starting point for the returned JFileChooser.
        Returns:
        the JFileChooser that interacted with the user, after they are finished using it - null if no file was chosen
        See Also:
        promptToOpenFile()
      • promptToSaveFile

        public static JFileChooser promptToSaveFile​(String filename,
                                                    String[] extensions)
        Get a JFileChooser with a new FileFilter.
        Parameters:
        filename - file name
        extensions - list of extensions
        Returns:
        the FileChooser - null if no file was chosen
      • getLastJFCDirectory

        public static String getLastJFCDirectory()
        Returns:
        The last directory visited by the user while choosing Files
      • setLastJFCDirectory

        public static void setLastJFCDirectory​(String lastJFCDirectory)
        Parameters:
        lastJFCDirectory - The last directory visited by the user while choosing Files