本文整理汇总了Java中javax.swing.filechooser.FileNameExtensionFilter.getExtensions方法的典型用法代码示例。如果您正苦于以下问题:Java FileNameExtensionFilter.getExtensions方法的具体用法?Java FileNameExtensionFilter.getExtensions怎么用?Java FileNameExtensionFilter.getExtensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.filechooser.FileNameExtensionFilter
的用法示例。
在下文中一共展示了FileNameExtensionFilter.getExtensions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addChoosableFileFilter
import javax.swing.filechooser.FileNameExtensionFilter; //导入方法依赖的package包/类
@Override
public void addChoosableFileFilter(FileFilter filter) {
super.addChoosableFileFilter(filter);
if (!FX_AVAILABLE || filter == null) {
return;
}
if (filter.getClass().equals(FileNameExtensionFilter.class)) {
FileNameExtensionFilter f = (FileNameExtensionFilter) filter;
List<String> ext = new ArrayList<>();
for (String extension : f.getExtensions()) {
ext.add(extension.replaceAll("^\\*?\\.?(.*)$", "*.$1"));
}
fileChooser.getExtensionFilters()
.add(new FileChooser.ExtensionFilter(f.getDescription(), ext));
}
}
示例2: addExtensionIfRequired
import javax.swing.filechooser.FileNameExtensionFilter; //导入方法依赖的package包/类
/**
* Adds the extension to the file if required
*
* @param file
* @param fileFilter
* @return File
*/
private File addExtensionIfRequired(File file, FileFilter fileFilter) {
String name = file.getName();
// If there is an extension
if (name.indexOf('.', name.length() - 4) >= 0) {
return file;
}
if (fileFilter instanceof FileNameExtensionFilter) {
FileNameExtensionFilter extensions = (FileNameExtensionFilter) fileFilter;
return new File(file.getAbsolutePath() + '.' + extensions.getExtensions()[0]);
}
return file;
}
示例3: setFileFilter
import javax.swing.filechooser.FileNameExtensionFilter; //导入方法依赖的package包/类
@Override
public void setFileFilter(FileFilter filter) {
super.setFileFilter(filter);
removeImagePreview();
if (filter instanceof FileNameExtensionFilter) {
FileNameExtensionFilter fileNameExtensionFilter = (FileNameExtensionFilter) filter;
String[] extensions = fileNameExtensionFilter.getExtensions();
for (String extension : extensions) {
if (FileUtil.hasTextureExtension(extension)) {
addImagePreview();
}
}
}
}