Class AbstractFileChooser

    • Field Detail

      • locale

        protected static volatile Locale locale
        The locale for both implementations
    • Method Detail

      • setDefaultLocale

        public static void setDefaultLocale​(Locale l)
        Sets the default locale for all implementations.
        Parameters:
        l - locale
      • getSelectedFile

        public abstract File getSelectedFile()
        Returns the selected file. This can be set either by the programmer via setSelectedFile or by a user action, such as either typing the filename into the UI or selecting the file from a list in the UI.
        Returns:
        the selected file
        See Also:
        setSelectedFile(java.io.File)
      • getSelectedFiles

        public abstract File[] getSelectedFiles()
        Returns a list of selected files if the file chooser is set to allow multiple selection.
        Returns:
        a list of selected files if the file chooser is set to allow multiple selection, or an empty array otherwise.
      • setAcceptAllFileFilterUsed

        public abstract void setAcceptAllFileFilterUsed​(boolean b)
        Determines whether the AcceptAll FileFilter is used as an available choice in the choosable filter list. If false, the AcceptAll file filter is removed from the list of available file filters. If true, the AcceptAll file filter will become the the actively used file filter.
        Parameters:
        b - whether the AcceptAll FileFilter is used as an available choice in the choosable filter list
        See Also:
        setFileFilter(javax.swing.filechooser.FileFilter)
      • setCurrentDirectory

        public abstract void setCurrentDirectory​(File dir)
        Sets the current directory. Passing in null sets the file chooser to point to the user's default directory. This default depends on the operating system. It is typically the "My Documents" folder on Windows, and the user's home directory on Unix. If the file passed in as currentDirectory is not a directory, the parent of the file will be used as the currentDirectory. If the parent is not traversable, then it will walk up the parent tree until it finds a traversable directory, or hits the root of the file system.
        Parameters:
        dir - the current directory to point to
        See Also:
        getCurrentDirectory()
      • setDialogTitle

        public abstract void setDialogTitle​(String title)
        Sets the string that goes in the JFileChooser window's title bar.
        Parameters:
        title - the new String for the title bar
      • setFileFilter

        public abstract void setFileFilter​(FileFilter filter)
        Sets the current file filter. The file filter is used by the file chooser to filter out files from the user's view.
        Parameters:
        filter - the new current file filter to use
        See Also:
        getFileFilter()
      • setFileSelectionMode

        public abstract void setFileSelectionMode​(int selectionMode)
        Sets the JFileChooser to allow the user to just select files, just select directories, or select both files and directories. The default is JFilesChooser.FILES_ONLY.
        Parameters:
        selectionMode - the type of files to be displayed:
        • JFileChooser.FILES_ONLY
        • JFileChooser.DIRECTORIES_ONLY
        • JFileChooser.FILES_AND_DIRECTORIES
        Throws:
        IllegalArgumentException - if mode is an illegal file selection mode
      • setMultiSelectionEnabled

        public abstract void setMultiSelectionEnabled​(boolean multiple)
        Sets the file chooser to allow multiple file selections.
        Parameters:
        multiple - true if multiple files may be selected
        See Also:
        isMultiSelectionEnabled()
      • setSelectedFile

        public abstract void setSelectedFile​(File file)
        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.
        Parameters:
        file - the selected file
        See Also:
        getSelectedFile()
      • showOpenDialog

        public abstract int showOpenDialog​(Component parent)
        Pops up an "Open File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F.
        Parameters:
        parent - the parent component of the dialog, can be null; see showDialog for details
        Returns:
        the return state of the file chooser on popdown:
        • JFileChooser.CANCEL_OPTION
        • JFileChooser.APPROVE_OPTION
        • JFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
        Throws:
        HeadlessException - if GraphicsEnvironment.isHeadless() returns true.
        See Also:
        GraphicsEnvironment.isHeadless()
      • showSaveDialog

        public abstract int showSaveDialog​(Component parent)
        Pops up a "Save File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F.
        Parameters:
        parent - the parent component of the dialog, can be null; see showDialog for details
        Returns:
        the return state of the file chooser on popdown:
        • JFileChooser.CANCEL_OPTION
        • JFileChooser.APPROVE_OPTION
        • JFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
        Throws:
        HeadlessException - if GraphicsEnvironment.isHeadless() returns true.
        See Also:
        GraphicsEnvironment.isHeadless()
      • getActionMap

        public abstract ActionMap getActionMap()
        Gets the list of action names.
        Returns:
        a ActionMap array containing all the action names
        Since:
        18113