本文整理了Java中javax.swing.JFileChooser.getChoosableFileFilters()
方法的一些代码示例,展示了JFileChooser.getChoosableFileFilters()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.getChoosableFileFilters()
方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:getChoosableFileFilters
暂无
代码示例来源:origin: chewiebug/GCViewer
@Override
public void actionPerformed(final ActionEvent e) {
final GCDocument gcDocument = gcViewer.getSelectedGCDocument();
for (int i=0; i<gcDocument.getChartPanelViewCount(); i++) {
final ChartPanelView chartPanelView = gcDocument.getChartPanelView(i);
final File file = new File(chartPanelView.getGCResource().getResourceName());
saveDialog.setCurrentDirectory(file.getParentFile());
saveDialog.setSelectedFile(file);
final int val = saveDialog.showSaveDialog(gcViewer);
if (val == JFileChooser.APPROVE_OPTION) {
ExportExtensionFileFilter fileFilter = (ExportExtensionFileFilter) saveDialog.getFileFilter();
// On OS/X if you don't select one of the filters and just press "Save" the filter may be null. Use the CSV one then
if (fileFilter==null) {
fileFilter = (ExportExtensionFileFilter) saveDialog.getChoosableFileFilters()[0];
}
exportFile(chartPanelView.getGCResource().getModel(),
saveDialog.getSelectedFile(),
fileFilter.getExtension(),
fileFilter.getDataWriterType());
}
else if (val == JFileChooser.ERROR_OPTION) {
JOptionPane.showMessageDialog(gcViewer, LocalisationHelper.getString("fileexport_dialog_error_occured"), LocalisationHelper.getString("fileexport_dialog_write_file_failed"), JOptionPane.ERROR_MESSAGE);
}
}
}
代码示例来源:origin: senbox-org/snap-desktop
@Override
public FileFilter[] getChoosableFileFilters() {
synchronized (syncFileFiltersObject) {
return super.getChoosableFileFilters();
}
}
代码示例来源:origin: sing-group/GC4S
private static List<FileFilter> getFileFilters(JFileChooser fileChooser) {
return Arrays.asList(fileChooser.getChoosableFileFilters());
}
代码示例来源:origin: sing-group/GC4S
private static List<FileFilter> getFileFilters(JFileChooser fileChooser) {
return Arrays.asList(fileChooser.getChoosableFileFilters());
}
代码示例来源:origin: orbisgis/orbisgis
/**
* Set the selected file filter
* @return True if the filter has been found and set
* @see getCurrentFilterId
*/
public boolean setCurrentFilter(int filterIdentifier) {
for(FileFilter filter : fileChooser.getChoosableFileFilters()) {
if(filter.hashCode()==filterIdentifier) {
fileChooser.setFileFilter(filter);
return true;
}
}
return false;
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
protected FilterComboBoxModel()
{
super();
filters= getFileChooser().getChoosableFileFilters();
}
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core
private static void clearFileFilters() {
FileFilter[] filters = jfc.getChoosableFileFilters();
for (FileFilter filter : filters) {
jfc.removeChoosableFileFilter(filter);
}
}
代码示例来源:origin: sdedit/sdedit
public static void setExtension(JFileChooser fileChooser, String extension) {
for (FileFilter ff : fileChooser.getChoosableFileFilters()) {
if (ff instanceof FF) {
if (((FF) ff).getExtension().equals(extension.toUpperCase())) {
fileChooser.setFileFilter(ff);
return;
}
}
}
}
代码示例来源:origin: org.gephi/directory-chooser
protected FilterTypeComboBoxModel() {
super();
filters = getFileChooser().getChoosableFileFilters();
}
代码示例来源:origin: monster860/FastDMM
private void openDME() {
JFileChooser fc = new JFileChooser();
if (fc.getChoosableFileFilters().length > 0)
fc.removeChoosableFileFilter(fc.getChoosableFileFilters()[0]);
fc.addChoosableFileFilter(new FileNameExtensionFilter("BYOND Environments (*.dme)", "dme"));
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
openDME(fc.getSelectedFile());
}
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
private static void limpaChooser(JFileChooser chooser) {
chooser.setCurrentDirectory(new File("."));
chooser.setSelectedFile(null);
chooser.setFileFilter(null);
chooser.setAcceptAllFileFilterUsed(true);
chooser.setMultiSelectionEnabled(false);
FileFilter filtros[] = chooser.getChoosableFileFilters();
for (FileFilter filtro : filtros) {
chooser.removeChoosableFileFilter(filtro);
}
}
代码示例来源:origin: sdedit/sdedit
public void addFileTypes(String... types) {
for (String type : types) {
fileTypes.add(type.toLowerCase());
}
if (fileChooser().getChoosableFileFilters().length == 1) {
fileChooser().addChoosableFileFilter(fileFilter);
}
}
代码示例来源:origin: girtel/Net2Plan
private void checkFileChooser(File currentFolder) {
if (fileChooser == null) {
fileChooser = currentFolder == null ? new JFileChooser() : new JFileChooser(currentFolder);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
for (FileFilter aux : fileChooser.getChoosableFileFilters()) fileChooser.removeChoosableFileFilter(aux);
fileChooser.addChoosableFileFilter(ClassLoaderUtils.getFileFilter());
fileChooser.setAcceptAllFileFilterUsed(false);
}
}
代码示例来源:origin: freeplane/freeplane
private void preselectFileFilter() {
final String lastChoosenExportFileFilter = ResourceController.getResourceController().getProperty(LAST_CHOOSEN_EXPORT_FILE_FILTER, null);
final FileFilter[] choosableFileFilters = fileChooser.getChoosableFileFilters();
for (FileFilter f: choosableFileFilters){
if(f.getDescription().equals(lastChoosenExportFileFilter)) {
fileChooser.setFileFilter(f);
return;
}
}
final FileFilter fileFilter = choosableFileFilters[0];
fileChooser.setFileFilter(fileFilter);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
private void onExportFilenameBrowseClick() {
File oldFile = getExecutableFile();
JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(MercurialOptionsPanelController.class, "ACSD_ExportBrowseFolder"), oldFile); // NOI18N
fileChooser.setDialogTitle(NbBundle.getMessage(MercurialOptionsPanelController.class, "ExportBrowse_title")); // NOI18N
fileChooser.setMultiSelectionEnabled(false);
FileFilter[] old = fileChooser.getChoosableFileFilters();
for (int i = 0; i < old.length; i++) {
FileFilter fileFilter = old[i];
fileChooser.removeChoosableFileFilter(fileFilter);
}
fileChooser.showDialog(panel, NbBundle.getMessage(MercurialOptionsPanelController.class, "OK_Button")); // NOI18N
File f = fileChooser.getSelectedFile();
if (f != null) {
panel.exportFilenameTextField.setText(f.getAbsolutePath());
}
}
代码示例来源:origin: sdedit/sdedit
public static void addExtension(JFileChooser fileChooser, String extension,
String description) {
FileFilter existing = null;
for (FileFilter ff : fileChooser.getChoosableFileFilters()) {
if (ff instanceof FF) {
if (((FF) ff).getExtension().equals(extension.toUpperCase())) {
existing = ff;
break;
}
}
}
if (existing != null) {
fileChooser.removeChoosableFileFilter(existing);
}
fileChooser.addChoosableFileFilter(new FF(extension, description));
}
代码示例来源:origin: igvteam/igv
private static File[] chooseMultipleSwing(String title, File initialDirectory, final FilenameFilter filter) {
JFileChooser fileChooser = getJFileChooser(title, initialDirectory, null, filter, JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(true);
fileChooser.addChoosableFileFilter(new AlignmentFileFilter());
fileChooser.addChoosableFileFilter(new CoverageFileFilter());
// set the default file filter to "All"
fileChooser.setFileFilter(fileChooser.getChoosableFileFilters()[0]);
boolean approve = fileChooser.showOpenDialog(getParentFrame()) == JFileChooser.APPROVE_OPTION;
if (approve) {
return fileChooser.getSelectedFiles();
} else {
return null;
}
}
代码示例来源:origin: orbisgis/orbisgis
public void setValue(String fieldName, String fieldValue) {
if (fieldName.equals(FIELD_NAME)) {
String[] files = fieldValue.split("\\Q||\\E");
File[] selectedFiles = new File[files.length];
for (int i = 0; i < selectedFiles.length; i++) {
selectedFiles[i] = new File(files[i]);
}
getFileChooser().setSelectedFiles(selectedFiles);
} else {
FileFilter[] filters = getFileChooser().getChoosableFileFilters();
for (FileFilter fileFilter : filters) {
if (fieldValue.equals(fileFilter.getDescription())) {
getFileChooser().setFileFilter(fileFilter);
}
}
}
}
代码示例来源:origin: orbisgis/orbisgis
public void setValue(String fieldName, String fieldValue) {
if (fieldName.equals(FIELD_NAME)) {
String[] files = fieldValue.split("\\Q||\\E");
File[] selectedFiles = new File[files.length];
for (int i = 0; i < selectedFiles.length; i++) {
selectedFiles[i] = new File(files[i]);
}
getFileChooser().setSelectedFiles(selectedFiles);
} else {
FileFilter[] filters = getFileChooser().getChoosableFileFilters();
for (FileFilter fileFilter : filters) {
if (fieldValue.equals(fileFilter.getDescription())) {
getFileChooser().setFileFilter(fileFilter);
}
}
}
}
代码示例来源:origin: orbisgis/orbisgis
public void setValue(String fieldName, String fieldValue) {
if (fieldName.equals(FIELD_NAME)) {
String[] files = fieldValue.split("\\Q||\\E");
File[] selectedFiles = new File[files.length];
for (int i = 0; i < selectedFiles.length; i++) {
selectedFiles[i] = new File(files[i]);
}
getFileChooser().setSelectedFiles(selectedFiles);
} else {
FileFilter[] filters = getFileChooser().getChoosableFileFilters();
for (FileFilter fileFilter : filters) {
if (fieldValue.equals(fileFilter.getDescription())) {
getFileChooser().setFileFilter(fileFilter);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!