本文整理汇总了Java中org.openide.filesystems.FileChooserBuilder.addFileFilter方法的典型用法代码示例。如果您正苦于以下问题:Java FileChooserBuilder.addFileFilter方法的具体用法?Java FileChooserBuilder.addFileFilter怎么用?Java FileChooserBuilder.addFileFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileChooserBuilder
的用法示例。
在下文中一共展示了FileChooserBuilder.addFileFilter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareFileChooser
import org.openide.filesystems.FileChooserBuilder; //导入方法依赖的package包/类
/**
* Creates and initializes a file chooser.
*
* @return the initialized file chooser
*/
protected JFileChooser prepareFileChooser() {
FileChooserBuilder fcb = new FileChooserBuilder(OpenFileAction.class);
fcb.setSelectionApprover(new OpenFileSelectionApprover());
fcb.setFilesOnly(true);
fcb.addDefaultFileFilters();
for (OpenFileDialogFilter filter :
Lookup.getDefault().lookupAll(OpenFileDialogFilter.class)) {
fcb.addFileFilter(filter);
}
JFileChooser chooser = fcb.createFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.getCurrentDirectory().listFiles(); //preload
chooser.setCurrentDirectory(getCurrentDirectory());
if (currentFileFilter != null) {
for (FileFilter ff : chooser.getChoosableFileFilters()) {
if (currentFileFilter.equals(ff.getDescription())) {
chooser.setFileFilter(ff);
break;
}
}
}
HelpCtx.setHelpIDString(chooser, getHelpCtx().getHelpID());
return chooser;
}
示例2: initFcb
import org.openide.filesystems.FileChooserBuilder; //导入方法依赖的package包/类
private static FileChooserBuilder initFcb(Class clazz, String title, List<FileFilter> extraFilters, FileFilter selectedFilter) {
FileChooserBuilder fcb = new FileChooserBuilder(clazz==null? FileDialog.class : clazz);
fcb.setBadgeProvider(BADGE_PROVIDER);
if(title != null)
fcb.setTitle(title);
if(extraFilters != null)
for(FileFilter filter : extraFilters)
fcb.addFileFilter(filter);
if(selectedFilter != null)
fcb.setFileFilter(selectedFilter);
return fcb;
}
示例3: selectFile
import org.openide.filesystems.FileChooserBuilder; //导入方法依赖的package包/类
private File selectFile() {
FileChooserBuilder fcb = new FileChooserBuilder(GRScriptDataObject.class);
fcb.setTitle(Bundle.LBL_ExampleAction_Dialog_Title());
fcb.setApproveText(Bundle.LBL_ExampleAction_Dialog_Approve());
fcb.addFileFilter(GRScriptFileFilter.getDefault());
fcb.setFileFilter(GRScriptFileFilter.getDefault());
return fcb.showSaveDialog();
}
示例4: getFiles
import org.openide.filesystems.FileChooserBuilder; //导入方法依赖的package包/类
private File[] getFiles() {
FileChooserBuilder fcb = new FileChooserBuilder(AddClassPathItemAction.class);
fcb.setTitle(Bundle.CTL_AddClassPathItemAction_Dialog_Title());
fcb.setApproveText(Bundle.CTL_AddClassPathItemAction_Dialog_Approve());
fcb.addFileFilter(JavaSourceFilter.getInstance());
fcb.setFileFilter(JavaSourceFilter.getInstance());
return fcb.showMultiOpenDialog();
}
示例5: selectFiles
import org.openide.filesystems.FileChooserBuilder; //导入方法依赖的package包/类
private File[] selectFiles() {
FileChooserBuilder fcb = new FileChooserBuilder(GRScriptDataObject.class);
fcb.setTitle(Bundle.LBL_OpenScriptsAction_Dialog_Title());
fcb.setApproveText(Bundle.LBL_OpenScriptsAction_Dialog_Approve());
fcb.addFileFilter(GRScriptFileFilter.getDefault());
fcb.setFileFilter(GRScriptFileFilter.getDefault());
return fcb.showMultiOpenDialog();
}
示例6: selectFile
import org.openide.filesystems.FileChooserBuilder; //导入方法依赖的package包/类
private File selectFile() {
FileChooserBuilder fcb = new FileChooserBuilder(GRScriptDataObject.class);
fcb.setTitle(Bundle.LBL_CreateScriptAction_Dialog_Title());
fcb.setApproveText(Bundle.LBL_CreateScriptAction_Dialog_Approve());
fcb.addFileFilter(GRScriptFileFilter.getDefault());
fcb.setFileFilter(GRScriptFileFilter.getDefault());
return fcb.showSaveDialog();
}
示例7: save
import org.openide.filesystems.FileChooserBuilder; //导入方法依赖的package包/类
public void save() throws IOException {
FileChooserBuilder builder = new FileChooserBuilder(NewSceneSaveNode.class);
builder.addFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
if (f.getName().toLowerCase().trim().endsWith(".j3o")) {
return true;
}
return false;
}
@Override
public String getDescription() {
return "j3o Files";
}
});
final File file = builder.showSaveDialog();
if (file == null) {
return;
}
SceneApplication.getApplication().enqueue(new Callable<Void>() {
public Void call() throws Exception {
Spatial node = request.getRootNode();
if (node == null) {
return null;
}
if (file.exists()) {
NotifyDescriptor.Confirmation mesg = new NotifyDescriptor.Confirmation("File exists, overwrite?",
"Not Saved",
NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(mesg);
if (mesg.getValue() != NotifyDescriptor.Confirmation.YES_OPTION) {
return null;
}
}
ProgressHandle progressHandle = ProgressHandle.createHandle("Saving File..");
progressHandle.start();
try {
BinaryExporter exp = BinaryExporter.getInstance();
exp.save(node, file);
} catch (Exception e) {
} finally {
FileObject fo = FileUtil.toFileObject(file);
if (fo != null) {
StatusDisplayer.getDefault().setStatusText(fo + " saved.");
fo.getParent().refresh();
}
}
progressHandle.finish();
return null;
}
});
}
示例8: requestFileAndSave
import org.openide.filesystems.FileChooserBuilder; //导入方法依赖的package包/类
private void requestFileAndSave() {
FileChooserBuilder builder = new FileChooserBuilder(ImageEditorComponent.class);
builder.addFileFilter(FileFilters.JPG);
builder.addFileFilter(FileFilters.TGA);
builder.addFileFilter(FileFilters.PNG);
JFileChooser fc = builder.createFileChooser();
fc.setFileSelectionMode(JFileChooser.SAVE_DIALOG);
fc.setAcceptAllFileFilterUsed(false);
int a = fc.showOpenDialog(COMPONENT);
if (a == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
String name = file.getName().toLowerCase();
String type;
if (name.endsWith(".png")) {
type = "png";
} else if (name.endsWith(".jpg") || name.endsWith(".jpeg")) {
type = "jpg";
} else if (name.endsWith(".bmp")) {
type = "bmp";
} else if (name.endsWith(".tga")) {
type = "tga";
} else {
ExtensionFileFilter filter = (ExtensionFileFilter) fc.getFileFilter();
file = new File(file.getParentFile(), file.getName() + filter.getExtension());
type = filter.getExtension().substring(1);
}
if (file.exists()) {
a = JOptionPane.showConfirmDialog(COMPONENT, "Overwrite existing file?", "Confirm", JOptionPane.YES_NO_OPTION);
if (a != JOptionPane.YES_OPTION) {
return;
}
}
try {
IOModule.create().store(editedImage, type, file);
Message msg = new NotifyDescriptor.Message("Image saved.");
DialogDisplayer.getDefault().notify(msg);
editedFile = FileUtil.toFileObject(file);
newFile = false;
owner.setName("PixelHead - " + editedFile.getName());
disableSaving();
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
}