本文整理汇总了Java中javax.swing.JFileChooser.putClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.putClientProperty方法的具体用法?Java JFileChooser.putClientProperty怎么用?Java JFileChooser.putClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.putClientProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: select
import javax.swing.JFileChooser; //导入方法依赖的package包/类
private static boolean select(
final PathModel model,
final File[] currentDir,
final Component parentComponent) {
final JFileChooser chooser = new JFileChooser ();
chooser.setMultiSelectionEnabled (true);
String title = null;
String message = null;
String approveButtonName = null;
String approveButtonNameMne = null;
if (model.type == SOURCES) {
title = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenSources");
message = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_Sources");
approveButtonName = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenSources");
approveButtonNameMne = NbBundle.getMessage (J2SEPlatformCustomizer.class,"MNE_OpenSources");
} else if (model.type == JAVADOC) {
title = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenJavadoc");
message = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_Javadoc");
approveButtonName = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenJavadoc");
approveButtonNameMne = NbBundle.getMessage (J2SEPlatformCustomizer.class,"MNE_OpenJavadoc");
}
chooser.setDialogTitle(title);
chooser.setApproveButtonText(approveButtonName);
chooser.setApproveButtonMnemonic (approveButtonNameMne.charAt(0));
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
if (Utilities.isMac()) {
//New JDKs and JREs are bundled into package, allow JFileChooser to navigate in
chooser.putClientProperty("JFileChooser.packageIsTraversable", "always"); //NOI18N
}
//#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
chooser.setAcceptAllFileFilterUsed( false );
chooser.setFileFilter (new ArchiveFileFilter(message,new String[] {"ZIP","JAR"})); //NOI18N
if (currentDir[0] != null) {
chooser.setCurrentDirectory(currentDir[0]);
}
if (chooser.showOpenDialog(parentComponent) == JFileChooser.APPROVE_OPTION) {
File[] fs = chooser.getSelectedFiles();
boolean addingFailed = false;
for (File f : fs) {
//XXX: JFileChooser workaround (JDK bug #5075580), double click on folder returns wrong file
// E.g. for /foo/src it returns /foo/src/src
// Try to convert it back by removing last invalid name component
if (!f.exists()) {
File parent = f.getParentFile();
if (parent != null && f.getName().equals(parent.getName()) && parent.exists()) {
f = parent;
}
}
if (f.exists()) {
addingFailed|=!model.addPath (f);
}
}
if (addingFailed) {
new NotifyDescriptor.Message (NbBundle.getMessage(J2SEPlatformCustomizer.class,"TXT_CanNotAddResolve"),
NotifyDescriptor.ERROR_MESSAGE);
}
currentDir[0] = FileUtil.normalizeFile(chooser.getCurrentDirectory());
return true;
}
return false;
}
示例2: createProjectChooser
import javax.swing.JFileChooser; //导入方法依赖的package包/类
/** Factory method for project chooser
*/
public static JFileChooser createProjectChooser( boolean defaultAccessory ) {
ProjectManager.getDefault().clearNonProjectCache(); // #41882
OpenProjectListSettings opls = OpenProjectListSettings.getInstance();
JFileChooser chooser = new ProjectFileChooser();
chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
if ("GTK".equals(javax.swing.UIManager.getLookAndFeel().getID())) { // NOI18N
// see BugTraq #5027268
chooser.putClientProperty("GTKFileChooser.showDirectoryIcons", Boolean.TRUE); // NOI18N
//chooser.putClientProperty("GTKFileChooser.showFileIcons", Boolean.TRUE); // NOI18N
}
chooser.setApproveButtonText( NbBundle.getMessage( ProjectChooserAccessory.class, "BTN_PrjChooser_ApproveButtonText" ) ); // NOI18N
chooser.setApproveButtonMnemonic( NbBundle.getMessage( ProjectChooserAccessory.class, "MNM_PrjChooser_ApproveButtonText" ).charAt (0) ); // NOI18N
chooser.setApproveButtonToolTipText (NbBundle.getMessage( ProjectChooserAccessory.class, "BTN_PrjChooser_ApproveButtonTooltipText")); // NOI18N
// chooser.setMultiSelectionEnabled( true );
chooser.setDialogTitle( NbBundle.getMessage( ProjectChooserAccessory.class, "LBL_PrjChooser_Title" ) ); // NOI18N
//#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
chooser.setAcceptAllFileFilterUsed( false );
chooser.setFileFilter( ProjectDirFilter.INSTANCE );
// A11Y
chooser.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ProjectChooserAccessory.class, "AN_ProjectChooserAccessory"));
chooser.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectChooserAccessory.class, "AD_ProjectChooserAccessory"));
if ( defaultAccessory ) {
chooser.setAccessory(new ProjectChooserAccessory(chooser, opls.isOpenSubprojects()));
}
File currDir = null;
String dir = opls.getLastOpenProjectDir();
if ( dir != null ) {
File d = new File( dir );
if ( d.exists() && d.isDirectory() ) {
currDir = d;
}
}
FileUtil.preventFileChooserSymlinkTraversal(chooser, currDir);
new ProjectFileView(chooser);
return chooser;
}