当前位置: 首页>>代码示例>>Java>>正文


Java JFileChooser.showDialog方法代码示例

本文整理汇总了Java中javax.swing.JFileChooser.showDialog方法的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.showDialog方法的具体用法?Java JFileChooser.showDialog怎么用?Java JFileChooser.showDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFileChooser的用法示例。


在下文中一共展示了JFileChooser.showDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: browseLibraryButtonActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void browseLibraryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLibraryButtonActionPerformed
    JFileChooser chooser = new JFileChooser(ModuleUISettings.getDefault().getLastChosenLibraryLocation());
    File[] olds = convertStringToFiles(txtLibrary.getText().trim());
    chooser.setSelectedFiles(olds);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(true);
    chooser.addChoosableFileFilter(new JarZipFilter());
    int ret = chooser.showDialog(this, getMessage("LBL_Select"));
    if (ret == JFileChooser.APPROVE_OPTION) {
        File[] files =  chooser.getSelectedFiles();
        if (files.length == 0) {
            return;
        }
        String path = "";
        for (int i = 0; i < files.length; i++) {
            path = path + files[i] + ( i == files.length - 1 ? "" : File.pathSeparator);
        }
        txtLibrary.setText(path);
        ModuleUISettings.getDefault().setLastChosenLibraryLocation(files[0].getParentFile().getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:LibraryStartVisualPanel.java

示例2: selectDirectory

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public static String selectDirectory(Component component,String name,File pathToUse){

        JFileChooser chooser = new JFileChooser();
        boolean useIndicated = pathToUse != null;
        if (useIndicated && lastIndicatedPath == null){
            lastIndicatedPath = pathToUse;
        }

        chooser.setCurrentDirectory(useIndicated?lastIndicatedPath:lastChooserPath);
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
	int result = chooser.showDialog(component, name);
        if ( result == JFileChooser.APPROVE_OPTION){
            try{
                if(useIndicated){
                    lastIndicatedPath = chooser.getCurrentDirectory();
                }else{
                    lastChooserPath = chooser.getCurrentDirectory();
                }
                return chooser.getSelectedFile().getAbsolutePath();
            }catch(Exception e){e.printStackTrace();}
        }
        return null;
    }
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:24,代码来源:FileUtils.java

示例3: btnFileActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
@Messages({"TIT_Choose=Choose Directory To Check Out", "LBL_Select=Select"})
private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFileActionPerformed
    JFileChooser chooser = new JFileChooser(lastFolder);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setDialogTitle(TIT_Choose());

    chooser.setMultiSelectionEnabled(false);
    if (txtFolder.getText().trim().length() > 0) {
        File fil = new File(txtFolder.getText().trim());
        if (fil.exists()) {
            chooser.setSelectedFile(fil);
        }
    }
    int ret = chooser.showDialog(SwingUtilities.getWindowAncestor(this), LBL_Select());
    if (ret == JFileChooser.APPROVE_OPTION) {
        txtFolder.setText(chooser.getSelectedFile().getAbsolutePath());
        txtFolder.requestFocusInWindow();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CheckoutUI.java

示例4: openFile

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Open a file.
 */
protected void openFile() {
	JFileChooser jc = new JFileChooser();
	String pathName = userPreferences.getDiskImageDirectory();
	if (null == pathName) {
		pathName = ""; //$NON-NLS-1$
		}
	jc.setCurrentDirectory(new File(pathName));
	EmulatorFileFilter ff = new EmulatorFileFilter();
	jc.setFileFilter(ff);
	int rc = jc.showDialog(this, textBundle.get("Open")); //$NON-NLS-1$
	if (rc == 0) {
		userPreferences.setDiskImageDirectory(jc.getSelectedFile().getParent());
		UserPreferences.getInstance().save();
		addDiskExplorerTab(jc.getSelectedFile());
	}
}
 
开发者ID:marvinmalkowskijr,项目名称:applecommander,代码行数:20,代码来源:SwingAppleCommander.java

示例5: selectFile

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public static String selectFile(Component component, String name, String extension, File pathToUse){
       JFileChooser chooser = new JFileChooser();
       if(extension != null){        
           chooser.setFileFilter(new ExtensionFilter(extension));
       }
       
       boolean useGivenPath = pathToUse != null;
       if (useGivenPath && lastIndicatedPath == null){
           lastIndicatedPath = pathToUse;
       }
       chooser.setCurrentDirectory(useGivenPath?lastIndicatedPath:lastChooserPath);
int result = chooser.showDialog(component, name);
       if ( result == JFileChooser.APPROVE_OPTION){
           try{
               if(useGivenPath){
                   lastIndicatedPath = chooser.getCurrentDirectory();
               }else{
                   lastChooserPath = chooser.getCurrentDirectory();
               }
               String p = chooser.getSelectedFile().getAbsolutePath();
               if (extension.startsWith(".")){
                   if (p.endsWith(extension)){
                       return p;
                   }else{
                       return p + extension;
                   }
               }else{
                   if (p.endsWith(extension)){
                       return p;
                   }else{
                       return p + "." + extension;
                   }
               }
              
           }catch(Exception e){e.printStackTrace();}
       }

       return null;
   }
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:40,代码来源:FileUtils.java

示例6: browseLicenceButtonActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void browseLicenceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLicenceButtonActionPerformed
    JFileChooser chooser = new JFileChooser(ModuleUISettings.getDefault().getLastChosenLibraryLocation());
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    if (txtLicense.getText().trim().length() > 0) {
        chooser.setSelectedFile(new File(txtLicense.getText().trim()));
    }
    int ret = chooser.showDialog(this, getMessage("LBL_Select"));
    if (ret == JFileChooser.APPROVE_OPTION) {
        txtLicense.setText(chooser.getSelectedFile().getAbsolutePath());
        ModuleUISettings.getDefault().setLastChosenLibraryLocation(txtLicense.getText());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:LibraryStartVisualPanel.java

示例7: btnFileActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFileActionPerformed
// TODO add your handling code here:
        JFileChooser chooser = new JFileChooser(lastFolder);
        chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(InstallPanel.class, "TIT_Select_Artifact"));
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        chooser.setFileFilter(new FileFilter() {
            @Override
            public boolean accept(File f) {
                return (f.isDirectory() || f.getName().toLowerCase().endsWith(".jar"));//NOI18N
            }
            @Override
            public String getDescription() {
                return org.openide.util.NbBundle.getMessage(InstallPanel.class, "SEL_Jars");
            }
        });
        chooser.setMultiSelectionEnabled(false);
        if (txtFile.getText().trim().length() > 0) {
            File fil = new File(txtFile.getText().trim());
            if (fil.exists()) {
                chooser.setSelectedFile(fil);
            }
        }
        int ret = chooser.showDialog(SwingUtilities.getWindowAncestor(this), org.openide.util.NbBundle.getMessage(InstallPanel.class, "TIT_Select"));
        if (ret == JFileChooser.APPROVE_OPTION) {
            txtFile.setText(chooser.getSelectedFile().getAbsolutePath());
            txtFile.requestFocusInWindow();
        }

    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:InstallPanel.java

示例8: btnFileActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFileActionPerformed
    JFileChooser chooser = new JFileChooser(lastFolder);
    chooser.setDialogTitle(isJavadoc() ? NbBundle.getMessage(InstallDocSourcePanel.class, "TIT_Select_javadoc_zip")
                                       : NbBundle.getMessage(InstallDocSourcePanel.class, "TIT_Select_source_zip"));
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setFileFilter(new FileFilter() {
        @Override
        public boolean accept(File f) {
            return (f.isDirectory() || f.getName().toLowerCase().endsWith(".jar") || f.getName().toLowerCase().endsWith(".zip")); //NOI18N
        }
        @Override
        public String getDescription() {
            
            return isJavadoc() ? NbBundle.getMessage(InstallDocSourcePanel.class, "LBL_Select_javadoc_zip")
                               : NbBundle.getMessage(InstallDocSourcePanel.class, "LBL_Select_source_zip");
        }
    });
    chooser.setMultiSelectionEnabled(false);
    if (txtFile.getText().trim().length() > 0) {
        File fil = new File(txtFile.getText().trim());
        if (fil.exists()) {
            chooser.setSelectedFile(fil);
        }
    }
    int ret = chooser.showDialog(SwingUtilities.getWindowAncestor(this), BTN_Select());
    if (ret == JFileChooser.APPROVE_OPTION) {
        txtFile.setText(chooser.getSelectedFile().getAbsolutePath());
        txtFile.requestFocusInWindow();
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:InstallDocSourcePanel.java

示例9: onBrowse

import javax.swing.JFileChooser; //导入方法依赖的package包/类
protected void onBrowse(JTextField txt) {
    File oldFile = FileUtil.normalizeFile(new File(txt.getText()));
    JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(Repository.class, "ACSD_BrowseCertFile"), oldFile); // NOI18N
    fileChooser.setDialogTitle(NbBundle.getMessage(Repository.class, "Browse_title"));                                            // NOI18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.showDialog(this.getPanel(), NbBundle.getMessage(Repository.class, "OK_Button"));                                            // NOI18N
    File f = fileChooser.getSelectedFile();
    if (f != null) {
        txt.setText(f.getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ConnectionType.java

示例10: browseActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
@Messages("LBL_Select=Select")
private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
    JFileChooser jfc = new JFileChooser();
    
    jfc.setSelectedFile(new File(standard.getProjectLocation(), fileLocation.getText()));
    
    if (jfc.showDialog(this, Bundle.LBL_Select()) == JFileChooser.APPROVE_OPTION) {
        fileLocation.setText(standard.getProjectLocation().toURI().relativize(jfc.getSelectedFile().toURI()).getPath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AdvancedLocationPanel.java

示例11: jButton3ActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    JFileChooser jfc = new JFileChooser ();
    jfc.setFileSelectionMode(jfc.DIRECTORIES_ONLY);
    jfc.showDialog(this, "Choose a directory with cache files");
   

    File fi = jfc.getSelectedFile();
    
    try {
        if (fi==null || (!fi.exists() && !fi.isDirectory())) {
            System.err.println("I can't do that: " + fi);
            return;
        }
        CacheReader r = new CacheReader (fi);
        String[] s = r.getIDs();
        for (int i=0; i < s.length; i++) {
            File f = new File(s[i]);
            BufferedImage img = (BufferedImage) r.find(s[i]);
            ImagePanel ip = new ImagePanel(img);
            ip.setName ("c-" + s[i]);
            jTabbedPane2.insertTab(f.getName(), null, new JScrollPane(ip), f.toString(), 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ImageCacheTest.java

示例12: onExecPathBrowseClick

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void onExecPathBrowseClick() {
    File oldFile = getExportFile();
    JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(MercurialOptionsPanelController.class, "ACSD_BrowseFolder"), oldFile);   // NOI18N
    fileChooser.setDialogTitle(NbBundle.getMessage(MercurialOptionsPanelController.class, "Browse_title"));                                            // NOI18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.showDialog(panel, NbBundle.getMessage(MercurialOptionsPanelController.class, "OK_Button"));                                            // NOI18N
    File f = fileChooser.getSelectedFile();
    if (f != null) {
        panel.executablePathTextField.setText(f.getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:MercurialOptionsPanelController.java

示例13: addDirButtonActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void addDirButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addDirButtonActionPerformed
      JFileChooser chooser = FileEditor.createHackedFileChooser();
      chooser.setFileHidingEnabled(false);
      setHelpToChooser( chooser );
      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      chooser.setDialogTitle(getString("CTL_FileSystemPanel.Local_Dialog_Title"));

      if (lastDirFolder != null) {
          chooser.setCurrentDirectory(lastDirFolder);
      }

      if (chooser.showDialog(this,
                             getString("CTL_Approve_Button_Title"))
              == JFileChooser.APPROVE_OPTION) {
          File f = chooser.getSelectedFile();
          if ((f != null) && (f.isDirectory())) {
              lastDirFolder = f.getParentFile();

              String path = f.getAbsolutePath();
              if (! listModel.contains (path)) {
                  listModel.addElement (path);
              }
              fireValueChanged();
              
              pathList.setSelectedIndex(listModel.size() - 1);
          }
      }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:NbClassPathCustomEditor.java

示例14: btnIconActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void btnIconActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIconActionPerformed
    JFileChooser chooser = WizardUtils.getIconFileChooser(txtIcon.getText());
    int ret = chooser.showDialog(this, getMessage("LBL_Select")); // NOI18N
    if (ret == JFileChooser.APPROVE_OPTION) {
        File file =  chooser.getSelectedFile();
        txtIcon.setText(file.getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:NameAndLocationPanel.java

示例15: doSelectLoggingFolder

import javax.swing.JFileChooser; //导入方法依赖的package包/类
synchronized public void doSelectLoggingFolder() {
    JFileChooser c = new JFileChooser(lastLoggingFolder);
    c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int ret = c.showDialog(chip.getAeViewer().getFilterFrame(), "Select folder");
    if (ret != JFileChooser.APPROVE_OPTION) {
        return;
    }
    lastLoggingFolder = c.getSelectedFile().getPath();
    putString("lastLoggingFolder", lastLoggingFolder);
    tobiLogger = new TobiLogger(lastLoggingFolder + File.separator + "TimestampCalibrator", "SystemTimeMillis dtClockNs dtTsUs");
    tobiLogger.setAbsoluteTimeEnabled(true);
    tobiLogger.setEnabled(true);// creates log file
    tobiLogger.addComment("timestamp calibrator log file");

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:16,代码来源:TimestampCalibrator.java


注:本文中的javax.swing.JFileChooser.showDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。