protected void scanDirectory(File dir)
    {
        boolean ok    = true;
        File[]  files = ( fileFilter != null ? dir.listFiles(fileFilter) :
                                               dir.listFiles() );

        // Process all the FILES first
        for (int i = 0; i < files.length && ok; i++)
        {
            if (files[i].isFile())
                ok = processFile(files[i]);
        }

        // Process all the SUB-DIRECTORIES
        for (int i = 0; i < files.length && ok; i++)
        {
            if (files[i].isDirectory())
            {
                ok = processDirectory(files[i]);

                if (ok && subDirs) // recurse downward
                    scanDirectory(files[i]);
            }
        }
    }