-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.0, 1.0.1, 3.1, 1.0.2, 1.1, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.6, 1.1.7, 1.2.0, 1.2.2, 1.3.0
-
generic, x86, sparc
-
generic, solaris_2.3, solaris_2.4, solaris_2.5, solaris_2.5.1, solaris_7, windows_95, windows_nt
Name: mc57594 Date: 02/10/97
Windows NT 4.0, Service Pack 2
Pentium 120
Add a System.out.println to the accept method of Main.java
Compile the example (from Java Class examples (from 1.0.2, in which the bug also manifests itself)).
Run using java Main
Put any filter in you wish, the accept method is never called, and the list is
not filtered.
Code for Main.java follows:
import java.awt.*;
import java.io.*;
class Main extends Frame implements FilenameFilter {
FileDialog fd;
TextField tfDirectory = new TextField();
TextField tfFile = new TextField();
TextField tfFilter = new TextField();
Main() {
super("FileDialog Example");
add("West", new Button("Load"));
add("East", new Button("Save"));
Panel p = new Panel();
p.setLayout(new GridBagLayout());
addRow(p, new Label("directory:", Label.RIGHT), tfDirectory);
addRow(p, new Label("file:", Label.RIGHT), tfFile);
addRow(p, new Label("filter:", Label.RIGHT), tfFilter);
add("South", p);
pack();
show();
}
// Adds a row in a gridbag layout where the c2 is stretchy
// and c1 is not.
void addRow(Container cont, Component c1, Component c2) {
GridBagLayout gbl = (GridBagLayout)cont.getLayout();
GridBagConstraints c = new GridBagConstraints();
Component comp;
c.fill = GridBagConstraints.BOTH;
cont.add(c1);
gbl.setConstraints(c1, c);
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1.0;
cont.add(c2);
gbl.setConstraints(c2, c);
}
public boolean accept(File dir, String name) {
System.out.println("File "+dir+" String "+name);
if (fd.getMode() == FileDialog.LOAD) {
return name.lastIndexOf(tfFilter.getText()) > 0;
}
return true;
}
public boolean action(Event evt, Object what) {
boolean load = "Load".equals(what);
if (load || "Save".equals(what)) {
fd = new FileDialog(this, null,
load ? FileDialog.LOAD : FileDialog.SAVE);
fd.setDirectory(tfDirectory.getText());
fd.setFile(tfFile.getText());
fd.setFilenameFilter(this);
fd.show();
tfDirectory.setText(fd.getDirectory());
tfFile.setText(fd.getFile());
// Filter must be the same
if (fd.getFilenameFilter() != this) {
throw new RuntimeException("Internal error");
}
return true;
}
return false;
}
static public void main(String[] args) {
new Main();
}
}
company - Object Guild, Inc. , email - ###@###.###
======================================================================
- duplicates
-
JDK-4044943 Can't set filter in FileDialog
- Closed
-
JDK-1243038 MFileDialogPeer quietly ignores setFilenameFilter
- Closed
-
JDK-4024056 FileDialog doesn't envoke FilenameFilter in Win95
- Closed
-
JDK-4062249 FilenameFilter doesn't work with FileDialog
- Closed
-
JDK-4067485 Cannot set filter for Solaris File Dialog
- Closed
-
JDK-4265223 enabling user to set drop-down list item in Windows FileDialog
- Closed
- relates to
-
JDK-4746749 Should refine documentation that filename filters do not work on Windows
- Resolved
-
JDK-6959787 java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.html failed on 7b94
- Closed
-
JDK-4293697 FileDialog filter does not work on Solaris in directory traversal
- Resolved