Class FileFilterExt


  • public class FileFilterExt
    extends javax.swing.filechooser.FileFilter
    A simple file filter to select only files with the specified extensions for display in a JFileChooser instance.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String m_kDescription
      The description for this filter.
      private java.util.Vector m_kExtensionsVector
      An array of possible extensions.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileFilterExt​(java.lang.String kDescription)
      Create file filter given no initial extensions.
      FileFilterExt​(java.lang.String[] akExtensions, java.lang.String kDescription)
      Create file filter given the initial array of extensions.
      FileFilterExt​(java.lang.String kExtension, java.lang.String kDescription)
      Create file filter given the initial single extension.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(java.io.File kFile)
      FileFilter override.
      void addExtension​(java.lang.String kExtension)
      Add an extension to the list of possible extensions valid for this filter.
      java.lang.String getDescription()
      FileFilter override.
      void setDescription​(java.lang.String kDescription)
      Set the description of this filter as it should be returned by the getDescription override method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_kDescription

        private java.lang.String m_kDescription
        The description for this filter.
      • m_kExtensionsVector

        private java.util.Vector m_kExtensionsVector
        An array of possible extensions.
    • Constructor Detail

      • FileFilterExt

        public FileFilterExt​(java.lang.String kDescription)
        Create file filter given no initial extensions. Until at least one extension is added (see the addExtension method), the accept method will always return false.
        Parameters:
        kDescription - String containing the filter description
      • FileFilterExt

        public FileFilterExt​(java.lang.String kExtension,
                             java.lang.String kDescription)
        Create file filter given the initial single extension.
        Parameters:
        kExtension - String containing the initial extension
        kDescription - String containing the filter description
      • FileFilterExt

        public FileFilterExt​(java.lang.String[] akExtensions,
                             java.lang.String kDescription)
        Create file filter given the initial array of extensions.
        Parameters:
        akExtensions - String array containing the initial extensions
        kDescription - String containing the filter description
    • Method Detail

      • accept

        public boolean accept​(java.io.File kFile)
        FileFilter override. This function is called for each file in the current directory of the file dialog to test if it is a file with a valid extension. If so, it is accepted for display in the file dialog.
        Specified by:
        accept in class javax.swing.filechooser.FileFilter
        Parameters:
        kFile - the file whose name is to be tested for extension
        Returns:
        true if and only if the file has a valid extension
      • addExtension

        public void addExtension​(java.lang.String kExtension)
        Add an extension to the list of possible extensions valid for this filter.
        Parameters:
        kExtension - String containing the valid file extension which is case-sensitive
      • getDescription

        public java.lang.String getDescription()
        FileFilter override. This function is called just to access the description of the filter.
        Specified by:
        getDescription in class javax.swing.filechooser.FileFilter
        Returns:
        the description for the possible files
      • setDescription

        public void setDescription​(java.lang.String kDescription)
        Set the description of this filter as it should be returned by the getDescription override method.
        Parameters:
        kDescription - String containing the description