Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FileDialog

0 views
Skip to first unread message

Chris Allen (Symantec)

unread,
Feb 25, 2000, 3:00:00 AM2/25/00
to
On 25 Feb 2000 13:05:03 GMT, KWe...@Ascona.de wrote:
>I create an FileDialog like this:
>java.awt.FileDialog openFileDialog = new java.awt.FileDialog(this);
>I can set one FileName in the Dialog like
>openFileDialog.setFile("*.html");
>How can I set in this FileDialog several FileNames like(*.html, *.java
>..) and several FileTypes eg (HTML Files (*.html), JavaFiles (*.java


Hi Konny,

Use FileDialog.setFilenameFilter(java.io.FilenameFilter). FilenameFilter is
an interface that only has one method to override, accept(File dir, String
name). Create a class that inplements this interface, and add an accept()
method. Check for something like name.endsWith("html"), and use this to
only display the files you want to see.

If you are doing any Swing development, look into the JFileChooser
component. JFileChooser has more choices for setting the filter; you can
set multiple filters, and each one will appear nicely in the drop-down
list. JFileChooser is much nicer, in my opinion.

Chris Allen
Internet Tools Tech. Support
Symantec Corp.

Robert Piechuta

unread,
Mar 24, 2000, 3:00:00 AM3/24/00
to
Even implementing FilenameFilter with an accept method under Windows
98, and setting setFilenameFilter to an instance of the class, I
find:

setFilenameFilter in openFileDialog does not work at all.

First, debug shows that if no peer exists, setFilenameFilter just
exits. However, once the dialog has been made visible once, it makes
the call to its peer, but it still doesn't work:

The "accept" method is never called as determined by setting a
breakpoint in it.

Any clues as to why this does not work? Using VCafe 3.0c
Professional Edition.

Tim Dutton (Symantec)

unread,
Mar 24, 2000, 3:00:00 AM3/24/00
to
Robert,

I suggest that you post a question on one of the comp.lang.java
newsgroups (which is a standard USENET newsgroup). Also, you can go
to Sun's web site at www.javasoft.com for another resource concerning
Java programming issues.

Regards,

Tim Dutton
Internet Tools Technical Support
Symantec Corporation

0 new messages