First: please use code tags, it makes reading your code example a lot easier.
Second: your accept() method returns true if the file it is checking is a directory, so why do you expect it would do anything else? If you want to check if you have a file with the extension ".txt", then have the accept() method check for that

(hint: look at the
String method endsWith() )
Third: be precise in the naming of your variables. The accept() method receives a File as parameter, so why do you call that parameter "pathname"? To another reader looking at your code, a variable named "pathname" might suggest that a string is passed here.