1 | /*
|
---|
2 | Launch4j (http://launch4j.sourceforge.net/)
|
---|
3 | Cross-platform Java application wrapper for creating Windows native executables.
|
---|
4 |
|
---|
5 | Copyright (C) 2004, 2006 Grzegorz Kowal
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or modify
|
---|
8 | it under the terms of the GNU General Public License as published by
|
---|
9 | the Free Software Foundation; either version 2 of the License, or
|
---|
10 | (at your option) any later version.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful,
|
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | GNU General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program; if not, write to the Free Software
|
---|
19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
20 | */
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * Created on 2004-01-15
|
---|
24 | */
|
---|
25 | package net.sf.launch4j;
|
---|
26 |
|
---|
27 | import java.io.File;
|
---|
28 |
|
---|
29 | import javax.swing.filechooser.FileFilter;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * @author Copyright (C) 2004 Grzegorz Kowal
|
---|
33 | */
|
---|
34 | public class FileChooserFilter extends FileFilter {
|
---|
35 | String _description;
|
---|
36 | String[] _extensions;
|
---|
37 |
|
---|
38 | public FileChooserFilter(String description, String extension) {
|
---|
39 | _description = description;
|
---|
40 | _extensions = new String[] {extension};
|
---|
41 | }
|
---|
42 |
|
---|
43 | public FileChooserFilter(String description, String[] extensions) {
|
---|
44 | _description = description;
|
---|
45 | _extensions = extensions;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public boolean accept(File f) {
|
---|
49 | if (f.isDirectory()) {
|
---|
50 | return true;
|
---|
51 | }
|
---|
52 | String ext = Util.getExtension(f);
|
---|
53 | for (int i = 0; i < _extensions.length; i++) {
|
---|
54 | if (ext.toLowerCase().equals(_extensions[i].toLowerCase())) {
|
---|
55 | return true;
|
---|
56 | }
|
---|
57 | }
|
---|
58 | return false;
|
---|
59 | }
|
---|
60 |
|
---|
61 | public String getDescription() {
|
---|
62 | return _description;
|
---|
63 | }
|
---|
64 | }
|
---|