The FilenameFilter was designed to be used with a FileDialog.
Unfortunately, this is not supported on most platforms.
i.e. A FilenameFilter will not work with a FileDialog.
This has been listed as
Bug ID 4031440
on the Java Developer Connection site (you need to be a registered user to visit here).
Extract from Sun's response to this bug:
The main issue is that support for FilenameFilter in the FileDialog class was
never implemented on any platform -- it's not that there's a bug which needs
to be fixed, but that there's no code to run nor was the design ever
evaluated to see if it *could* be implemented on our target platforms.
...
Unfortunately this is not going to get addressed for 1.2, other than
having people use Swing's JFileChooser.
You may download simple hack (fdhack.java)
which I understand will work on some platforms.
This uses the call such as
fd.setFile("*.java");
(where fd is a FileDialog) to list all files ending with '.java'.
No FilenameFilter is used here.