本文整理汇总了Java中javax.swing.JFileChooser.FILES_ONLY属性的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.FILES_ONLY属性的具体用法?Java JFileChooser.FILES_ONLY怎么用?Java JFileChooser.FILES_ONLY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.FILES_ONLY属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSetFilesOnly
/**
* Test of setFilesOnly method, of class FileChooserBuilder.
*/
public void testSetFilesOnly() {
FileChooserBuilder instance = new FileChooserBuilder("y");
boolean filesOnly = instance.createFileChooser().getFileSelectionMode() == JFileChooser.FILES_ONLY;
assertFalse(filesOnly);
instance.setFilesOnly(true);
filesOnly = instance.createFileChooser().getFileSelectionMode() == JFileChooser.FILES_ONLY;
assertTrue(filesOnly);
}
示例2: CognizantITSFileChooser
public CognizantITSFileChooser(Image i, String title, SelectionMode selMode, File startIn, FileFilter selector) {
super(startIn);
ICON_14 = new ImageIcon(i.getScaledInstance(13, 13, 4));
this.selector = selector;
setDialogTitle(title);
setMultiSelectionEnabled(false);
setFileSelectionMode(selMode.ordinal());
setAcceptAllFileFilterUsed(false);
if (JFileChooser.FILES_ONLY != selMode.ordinal()) {
addPropertyChangeListener((PropertyChangeListener) this);
}
}
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:12,代码来源:CognizantITSFileChooser.java
示例3: attachEnv
/**
* This method is called by the IDE to pass
* the environment to the property editor.
* @param env Environment passed by the ide.
*/
public void attachEnv(PropertyEnv env) {
this.env = env;
// clearing to defaults
directories = true;
files = true;
fileFilter = null;
fileHiding = false;
Object dirs = env.getFeatureDescriptor().getValue(PROPERTY_SHOW_DIRECTORIES);
if (dirs instanceof Boolean) {
directories = ((Boolean)dirs).booleanValue();
} // XXX else if != null, warn
Object fil = env.getFeatureDescriptor().getValue(PROPERTY_SHOW_FILES);
if (fil instanceof Boolean) {
files = ((Boolean)fil).booleanValue();
} // XXX else if != null, warn
Object filter = env.getFeatureDescriptor().getValue(PROPERTY_FILTER);
if (filter instanceof FilenameFilter) {
fileFilter = new DelegatingFilenameFilter((FilenameFilter)filter);
} else if (filter instanceof javax.swing.filechooser.FileFilter) {
fileFilter = (javax.swing.filechooser.FileFilter)filter;
} else if (filter instanceof java.io.FileFilter) {
fileFilter = new DelegatingFileFilter((java.io.FileFilter)filter);
} // XXX else if != null, warn
Object curDir = env.getFeatureDescriptor().getValue(PROPERTY_CURRENT_DIR);
if (curDir instanceof File) {
currentDirectory = (File)curDir;
if(! currentDirectory.isDirectory()) {
Logger.getAnonymousLogger().warning("java.io.File will not accept currentDir=" + currentDirectory); // NOI18N
currentDirectory = null;
}
} // XXX else if != null, warn
Object baseDir = env.getFeatureDescriptor().getValue(PROPERTY_BASE_DIR);
if(baseDir instanceof File) {
baseDirectory = (File)baseDir;
// As baseDir accept only directories in their absolute form.
if(!baseDirectory.isDirectory() || !baseDirectory.isAbsolute()) {
Logger.getAnonymousLogger().warning("java.io.File will not accept baseDir=" + baseDirectory); // NOI18N
baseDirectory = null;
}
} // XXX else if != null, warn
if (files) {
mode = directories ? JFileChooser.FILES_AND_DIRECTORIES :
JFileChooser.FILES_ONLY;
} else {
mode = directories ? JFileChooser.DIRECTORIES_ONLY :
JFileChooser.FILES_AND_DIRECTORIES; // both false, what now? XXX warn
}
Object fileHide = env.getFeatureDescriptor().getValue(PROPERTY_FILE_HIDING);
if (fileHide instanceof Boolean) {
fileHiding = ((Boolean)fileHide).booleanValue();
}
if (env.getFeatureDescriptor() instanceof Node.Property){
Node.Property prop = (Node.Property)env.getFeatureDescriptor();
editable = prop.canWrite();
}
}