-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.1
-
None
-
x86
-
windows_95
Name: sg39081 Date: 07/01/97
/*
Compile and run this code. It allows you to see that filtering has not
effect on the file dialog under Win95 as documented.
"Instances of classes that implement this interface are used to filter
filenames. These instances are used to filter directory listings in the
list method of class File, and by the Abstract Window Toolkit's file
dialog component." ==============================
=================
Press the single button. See that although the the filter is supposed to
limit the files shown/selected to "*.java", it does not.
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class jdk111FileDialogFilterBug extends Frame
implements ActionListener,
FilenameFilter
{
public jdk111FileDialogFilterBug()
{
Button b = new Button("File Dialog");
add(b, "Center");
b.addActionListener(this);
doLayout();
pack();
show();
}
public void actionPerformed(ActionEvent e)
{
// show the user the file open dialog
FileDialog dialog = new FileDialog(this, "Filter Test", FileDialog.LOAD);
dialog.setFilenameFilter(this);
dialog.show();
// get the user's input
String dir = dialog.getDirectory();
String file = dialog.getFile();
// get rid of the file dialog
dialog.dispose();
// if the user pressed the Cancel button on the dialog, then
// the file will be null
if(null == file)
{
System.out.println("Cancel");
return;
}
// note the filename
System.out.println(dir + file);
}
/**
*** Filename filter to limit selections.
**/
public boolean accept(File dir, String name)
{
return(name.endsWith(".java"));
}
public static void main(String[] argv)
{
new jdk111FileDialogFilterBug();
}
}
======================================================================
- duplicates
-
JDK-4062249 FilenameFilter doesn't work with FileDialog
-
- Closed
-