1
2 package jmfexample;
3
4 import java.io.File;
5 import javax.swing.*;
6 import javax.swing.filechooser.*;
7
8
9 public class MOVFilter extends FileFilter {
10 public boolean accept(File f) {
11 if (f.isDirectory()) {
12 return true;
13 }
14
15 String extension = MOVFilter.getExtension(f);
16 if (extension != null) {
17 if (extension.equalsIgnoreCase("MOV")) {
18 return true;
19 } else {
20 return false;
21 }
22 }
23
24 return false;
25 }
26
27
28 public String getDescription() {
29 return "QuickTime Movies";
30 }
31
32 public static String getExtension(File f) {
33 String ext = null;
34 String s = f.getName();
35 int i = s.lastIndexOf('.');
36
37 if (i > 0 && i < s.length() - 1) {
38 ext = s.substring(i+1).toLowerCase();
39 }
40 return ext;
41 }
42 }
43
44