Article View: borland.public.jbuilder.java.language
Article #20132Re: How can I set the file filters in the filedialog?
From: Chris Hill
Date: Sun, 26 Oct 1997 00:00
Date: Sun, 26 Oct 1997 00:00
30 lines
1134 bytes
1134 bytes
In article <345214FD.4907DA6E@globalinfotek.com>,
jschnur@globalinfotek.com says...
>
>How can We set the file filter types like *.csv , *.txt, etc for the
>openfiledialog.?
>
Write a class that implements java.io.FilenameFilter.
For example:
public class MyFilter implements java.io.FilenameFilter
{
public boolean accept(File dir, String name)
{
if(name.endsWith(".csv") || name.endsWith(".txt"))
return true;
else
return false;
}
}
Now call MyFileDialog.setFilenameFilter(new MyFilter()).
--
Chris Hill
hillca@cs.purdue.edu
Technical Details
Message-ID:
<62ug25$3e36@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<345214FD.4907DA6E@globalinfotek.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10a146,92945f7790f60b99 X-Google-Attributes: gid10a146,public X-Google-Thread: f74b3,92945f7790f60b99 X-Google-Attributes: gidf74b3,public From: hillca@cs.purdue.edu (Chris Hill) Subject: Re: How can I set the file filters in the filedialog? Date: 1997/10/26 Message-ID: <62ug25$3e36@forums.borland.com> X-Deja-AN: 285000249 References: <345214FD.4907DA6E@globalinfotek.com> Organization: None Newsgroups: borland.public.jbuilder.java.language,comp.lang.java.programmer