java.awt.FileDialog.setFilenameFilter()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(307)

本文整理了Java中java.awt.FileDialog.setFilenameFilter()方法的一些代码示例,展示了FileDialog.setFilenameFilter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileDialog.setFilenameFilter()方法的具体详情如下:
包路径:java.awt.FileDialog
类名称:FileDialog
方法名:setFilenameFilter

FileDialog.setFilenameFilter介绍

暂无

代码示例

代码示例来源:origin: redwarp/9-Patch-Resizer

fileDialog.setFilenameFilter(new FilenameFilter() {
 @Override
 public boolean accept(File dir, String name) {

代码示例来源:origin: nodebox/nodebox

private static File showFileDialog(Frame owner, String pathName, String extensions, String description, int fileDialogType) {
  FileDialog fileDialog = new FileDialog(owner, pathName, fileDialogType);
  fileDialog.setFilenameFilter(new FileExtensionFilter(extensions, description));
  fileDialog.setVisible(true);
  String chosenFile = fileDialog.getFile();
  String dir = fileDialog.getDirectory();
  if (chosenFile != null) {
    return new File(dir + chosenFile);
  } else {
    return null;
  }
}

代码示例来源:origin: nodebox/nodebox

fileDialog.setFilenameFilter(new FileExtensionFilter(extensions, description));
fileDialog.setVisible(true);
String chosenFile = fileDialog.getFile();

代码示例来源:origin: apache/pdfbox

openDialog.setFilenameFilter(new FilenameFilter()

代码示例来源:origin: igniterealtime/Spark

public void initFileChooser() {
  if (fileChooser == null) {
    fileChooser = new FileDialog(dlg, "Choose Avatar", FileDialog.LOAD);
    fileChooser.setFilenameFilter(new ImageFilter());
  }
}

代码示例来源:origin: stackoverflow.com

DateFileFilter filter = new DateFileFilter();
FileDialog dialog = new FileDialog(parent, "Choose File");   

    dialog.setFilenameFilter(filter);  

    dialog.show();  

    String selectedFile = dialog.getFile();

代码示例来源:origin: openpnp/openpnp

public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(Dlg.this);
    fileDialog.setFilenameFilter(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".csv");
      }
    });
    fileDialog.setVisible(true);
    if (fileDialog.getFile() == null) {
      return;
    }
    File file = new File(new File(fileDialog.getDirectory()), fileDialog.getFile());
    textFieldFileName.setText(file.getAbsolutePath());
  }
}

代码示例来源:origin: openpnp/openpnp

public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(KicadPosImporterDialog.this);
    fileDialog.setFilenameFilter(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".pos");
      }
    });
    fileDialog.setVisible(true);
    if (fileDialog.getFile() == null) {
      return;
    }
    File file = new File(new File(fileDialog.getDirectory()), fileDialog.getFile());
    textFieldTopFile.setText(file.getAbsolutePath());
  }
}

代码示例来源:origin: openpnp/openpnp

public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(Dlg.this);
    fileDialog.setFilenameFilter(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".brd");
      }
    });
    fileDialog.setVisible(true);
    if (fileDialog.getFile() == null) {
      return;
    }
    File file = new File(new File(fileDialog.getDirectory()), fileDialog.getFile());
    textFieldBoardFile.setText(file.getAbsolutePath());
  }
}

代码示例来源:origin: openpnp/openpnp

public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(KicadPosImporterDialog.this);
    fileDialog.setFilenameFilter(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".pos");
      }
    });
    fileDialog.setVisible(true);
    if (fileDialog.getFile() == null) {
      return;
    }
    File file = new File(new File(fileDialog.getDirectory()), fileDialog.getFile());
    textFieldBottomFile.setText(file.getAbsolutePath());
  }
}

代码示例来源:origin: openpnp/openpnp

public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(Dlg.this);
    fileDialog.setFilenameFilter(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".mnb");
      }
    });
    fileDialog.setVisible(true);
    if (fileDialog.getFile() == null) {
      return;
    }
    File file = new File(new File(fileDialog.getDirectory()), fileDialog.getFile());
    textFieldBottomFile.setText(file.getAbsolutePath());
  }
}

代码示例来源:origin: openpnp/openpnp

public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(Dlg.this);
    fileDialog.setFilenameFilter(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".mnt");
      }
    });
    fileDialog.setVisible(true);
    if (fileDialog.getFile() == null) {
      return;
    }
    File file = new File(new File(fileDialog.getDirectory()), fileDialog.getFile());
    textFieldTopFile.setText(file.getAbsolutePath());
  }
}

代码示例来源:origin: openpnp/openpnp

public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(Dlg.this);
    fileDialog.setFilenameFilter(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return false || name.toLowerCase().endsWith(".csv")
            || name.toLowerCase().endsWith(".txt")
            || name.toLowerCase().endsWith(".dat");
      }
    });
    fileDialog.setVisible(true);
    if (fileDialog.getFile() == null) {
      return;
    }
    File file = new File(new File(fileDialog.getDirectory()), fileDialog.getFile());
    textFieldTopFile.setText(file.getAbsolutePath());
  }
}

代码示例来源:origin: openpnp/openpnp

public void actionPerformed(ActionEvent e) {
  
  FileDialog fileDialog = new FileDialog(Dlg.this);
  fileDialog.setFilenameFilter(new FilenameFilter() {
    @Override
    public boolean accept(File dir, String name) {
      return name.toLowerCase().endsWith(".pkp");
    }
  });
  fileDialog.setFile("*.pkp");
  fileDialog.setVisible(true);
  if (fileDialog.getFile() == null) {
    return;
  }
  File file = new File(new File(fileDialog.getDirectory()), fileDialog.getFile());
  textFieldFileName.setText(file.getAbsolutePath());
}

代码示例来源:origin: com.itextpdf/itext-rups

public void actionPerformed(ActionEvent event) {
    try {
      FileDialog fileDialog = new FileDialog(new Frame(), "Save", FileDialog.SAVE);
      fileDialog.setFilenameFilter(new FilenameFilter() {
        public boolean accept(File dir, String name) {
          return name.endsWith(".jpg");
        }
      });
      fileDialog.setFile("Untitled.jpg");
      fileDialog.setVisible(true);
      ImageIO.write(saveImg, "jpg", new File(fileDialog.getDirectory() + fileDialog.getFile()));
    } catch (HeadlessException | IOException e) {
      LoggerHelper.error(LoggerMessages.IMAGE_PARSING_ERROR, e, getClass());
    }
  }
});

代码示例来源:origin: com.stevesoft.pat/pat

public void actionPerformed(ActionEvent ae) {
    FileDialog fd = new FileDialog(for_dialog,"Save",
      FileDialog.SAVE);
    Regex html = new Regex("\\.html?$");
    fd.setFile("*.html");
    fd.setFilenameFilter(html);
    fd.show();
    String NewFile = fd.getDirectory()+File.separator+
      fd.getFile();
    File from = new File(CurrentFile);
    File to = new File(NewFile);
    if(!to.exists()) newfile(NewFile);
    copy(from,to);
    CurrentFile = NewFile;
    savefile();
  }
});

代码示例来源:origin: us.ihmc/IHMCCommunication

@Override
public void actionPerformed(ActionEvent e)
{
  FileDialog dialog = new FileDialog(frame, "Choose ini file to load", FileDialog.LOAD);
  dialog.setFilenameFilter(new INIFileFilter());
  dialog.setVisible(true);
  String filename = dialog.getFile();
  if (filename == null)
  {
   return;
  }
  else
  {
   load(new File(dialog.getDirectory(), dialog.getFile()));
  }
}

代码示例来源:origin: org.ihtsdo/wb-api

public void run() {
    FileDialog dialog = new FileDialog(new Frame(), "Select a sync file to process");
    dialog.setDirectory(System.getProperty("user.dir"));
    dialog.setFilenameFilter(new FilenameFilter() {
      public boolean accept(File dir, String name) {
        return name.endsWith(".ucs");
      }
    });
    dialog.setVisible(true);
    if (dialog.getFile() == null) {
      ex = new TaskFailedException("User canceled operation");
    } else {
      jarFile = new File(dialog.getDirectory(), dialog.getFile());
    }
  }
});

代码示例来源:origin: org.ihtsdo/wb-api

public void run() {
    FileDialog dialog = new FileDialog(new Frame(), "Select a sync file to process");
    dialog.setDirectory(System.getProperty("user.dir"));
    dialog.setFilenameFilter(new FilenameFilter() {
      public boolean accept(File dir, String name) {
        return name.endsWith(".cus");
      }
    });
    dialog.setVisible(true);
    if (dialog.getFile() == null) {
      ex = new TaskFailedException("User canceled operation");
    } else {
      jarFile = new File(dialog.getDirectory(), dialog.getFile());
    }
  }
});

代码示例来源:origin: org.ihtsdo/wb-api

public void run() {
    FileDialog dialog = new FileDialog(new Frame(), "Select a profile to prepare sync pkg for:");
    dialog.setDirectory(System.getProperty("user.dir"));
    dialog.setFilenameFilter(new FilenameFilter() {
      public boolean accept(File dir, String name) {
        return name.endsWith(".ace");
      }
    });
    dialog.setVisible(true);
    if (dialog.getFile() == null) {
      ex = new TaskFailedException("User canceled operation");
    } else {
      remoteProfile = new File(dialog.getDirectory(), dialog.getFile());
    }
  }
});

相关文章