Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4355026

FilenameFilter in the FileDialog doesn't work after changing the directory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs
    • x86
    • linux



      Name: stC104175 Date: 07/20/2000


      ava version "1.3.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b07)
      Java HotSpot(TM) Client VM (build 1.3.0beta-b04, mixed mode)



      use the FileDialog with a FilenameFilter.
      when the dialog initially appears, the filter works fine.
      change the directory in the dialog by double clicking on a directory in the
      left pane. after the directory changes, the filename filter no longer works.

      for example, if you compile and run the following program, you will initially
      see any java files that you have in the current directory.
      if you change the directory, then you will see all files,
      even though the filter specifies that only java files should be displayed.

      import java.awt.Frame;
      import java.awt.FileDialog;
      import java.io.File;
      import java.io.FilenameFilter;

      public class FileDlg extends Frame
      {

      public static void main(String[] args)
      {
      new FileDlg();
      }

      public FileDlg()
      {
      setBounds(100,100,100,100);

      show();

      FileDialog dlg = new FileDialog(this, "select", FileDialog.LOAD);

      dlg.setFilenameFilter(new FileFilter());

      dlg.show();

      dispose();

      System.exit(0);
      }

      public class FileFilter implements FilenameFilter
      {
      public boolean accept(File dir, String name)
      {
      return name.endsWith( ".java" );
      }

      }

      }
      (Review ID: 106622)
      ======================================================================

            mmartaksunw Michael Martak (Inactive)
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: