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


Java JFileChooser.setCurrentDirectory方法代码示例

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


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

示例1: save

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public void save(final JPanel panel) {
	JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File(System.getProperty("user.dir")));
    chooser.setDialogTitle("Choose Directory To Save To");
    //chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setApproveButtonText("Save");
    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
      dir = chooser.getSelectedFile().toString();
    } else {
      System.err.println("Could not open Dir");
      return;
    }
}
 
开发者ID:JudgeGlass,项目名称:Install_Builder_Universal,代码行数:15,代码来源:SaveFile.java

示例2: selectFile

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private File selectFile(int dialogType, String approveButtonText) {
        JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(TemplateSelector.class, "ACSD_SelectTemplate")/*, defaultDir*/);// NOI18N
        fileChooser.setDialogTitle(NbBundle.getMessage(TemplateSelector.class, "CTL_SelectTemplate"));// NOI18N
        fileChooser.setMultiSelectionEnabled(false);
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fileChooser.setDialogType(dialogType);

        File file = getTemplateFile();

//        if(file.isFile() && dialogType == JFileChooser.OPEN_DIALOG) {
//            fileChooser.setSelectedFile(file);
//        } else {
//            fileChooser.setCurrentDirectory(file.isFile() ? file.getParentFile() : file);
//        }
        if(file.isFile() ) {
            fileChooser.setSelectedFile(file);
        } else {
            fileChooser.setCurrentDirectory(file);
        }

        fileChooser.showDialog(getPanel(), approveButtonText);
        File f = fileChooser.getSelectedFile();
        return f;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TemplateSelector.java

示例3: 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

示例4: doSetPath

import javax.swing.JFileChooser; //导入方法依赖的package包/类
synchronized public void doSetPath() {
	JFileChooser j = new JFileChooser();
	j.setCurrentDirectory(new File(dirPath));
	j.setApproveButtonText("Select");
	j.setDialogTitle("Select a folder and base file name for calibration images");
	j.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // let user specify a base filename
	int ret = j.showSaveDialog(null);
	if (ret != JFileChooser.APPROVE_OPTION) {
		return;
	}
	//imagesDirPath = j.getSelectedFile().getAbsolutePath();
	dirPath = j.getCurrentDirectory().getPath();
	fileBaseName = j.getSelectedFile().getName();
	if (!fileBaseName.isEmpty()) {
		fileBaseName = "-" + fileBaseName;
	}
	log.log(Level.INFO, "Changed images path to {0}", dirPath);
	putString("dirPath", dirPath);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:20,代码来源:StereoCalibrationDualViewFilter.java

示例5: selectAppBrowseB_actionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
void selectAppBrowseB_actionPerformed(ActionEvent e) {
// Fix until Sun's JVM supports more locales...
UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));
UIManager.put("FileChooser.acceptAllFileFilterText", Local.getString("All Files") + " (*.*)");

JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(Local.getString("Path to executable"));
chooser.setFileHidingEnabled(false);
chooser.setAcceptAllFileFilterUsed(true);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (System.getProperty("os.name").startsWith("Win")) {
    chooser.setFileFilter(new AllFilesFilter(AllFilesFilter.EXE));
    chooser.setCurrentDirectory(new File("C:\\Program Files"));
}
chooser.setPreferredSize(new Dimension(550, 375));
/*
    java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_IMPORT_FILE");
    if (lastSel != null)
        chooser.setCurrentDirectory(lastSel);
*/
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
    applicationField.setText(chooser.getSelectedFile().getPath());
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:34,代码来源:SetApplicationPanel.java

示例6: doSaveTrack

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Saves the extracted track to an external file.
 */
public void doSaveTrack() {
    if (extractedTrack == null) {
        // No track defined
        return;
    }

    final JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(getLastFilePrefs());  // defaults to startup runtime folder
    fc.setFileFilter(new FileFilter() {

        @Override
        public boolean accept(File f) {
            return f.isDirectory()
                    || f.getName().toLowerCase().endsWith(".track");
        }

        @Override
        public String getDescription() {
            return "Track files";
        }
    });

    final int[] state = new int[1];
    state[0] = Integer.MIN_VALUE;

    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            fc.setSelectedFile(new File("test.track"));
            state[0] = fc.showSaveDialog(chip.getAeViewer() != null && chip.getAeViewer().getFilterFrame() != null ? chip.getAeViewer().getFilterFrame() : null);
            if (state[0] == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                if(!file.getName().endsWith(".track")) {
                    String newName=file.getPath()+".track";
                    file=new File(newName);
                }
                putLastFilePrefs(file);

                try {
                    saveTrackToFile(file);
                } catch (IOException ex) {
                    log.warning("couldn't save track to file, caught: " + ex);
                    JOptionPane.showMessageDialog(fc, "couldn't save track to file, caught: " + ex, "Saving track failed", JOptionPane.WARNING_MESSAGE);
                }
            } else {
                log.info("Cancelled saving!");
            }
        }
    });
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:56,代码来源:TrackDefineFilter.java

示例7: SavedGameUpdaterDialog

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public SavedGameUpdaterDialog(Frame owner) throws HeadlessException {
  super(owner, false);
  setTitle("Update Saved Games");
  initComponents();
  fc = new JFileChooser();
  fc.setCurrentDirectory(GameModule.getGameModule().getFileChooser().getCurrentDirectory());
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:8,代码来源:SavedGameUpdaterDialog.java

示例8: browseTemplate

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void browseTemplate() {
	JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Select file"));
    chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    if (templF.getText().length() >0)
    	chooser.setCurrentDirectory(new java.io.File(templF.getText()));
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
    	templF.setText(chooser.getSelectedFile().getPath());
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:12,代码来源:FileExportDialog.java

示例9: jButton1ActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    JFileChooser NuevoF = new JFileChooser();
    NuevoF.setDialogTitle("Seleccione una Imagen");
    File ruta = new File("C:/Imagenes");
    NuevoF.setCurrentDirectory(ruta);
    int ventana = NuevoF.showOpenDialog(null);
    if(ventana == JFileChooser.APPROVE_OPTION)
    {
        File Foto= NuevoF.getSelectedFile();
        txtNombImg.setText(String.valueOf(Foto));
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:14,代码来源:JDIngresarPaciente.java

示例10: jButton1ActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    String filename = null;
    for (ILayer l : LayerManager.getIstanceManager().getLayers().keySet()) {
        if (l instanceof ImageLayer & l.isActive()) {
            filename = ((ImageLayer) l).getName();
            break;
        }
    }
    filename = jTextField1.getText();
    //System.out.println(filename);
    JFileChooser fd = new JFileChooser();
    if(!"".equalsIgnoreCase(filename)&&filename!=null){
    	File f=new File(filename);
    	if(f.getParentFile()!=null && f.getParentFile().exists())
    		fd.setCurrentDirectory(f.getParentFile());
    	
    	fd.setSelectedFile(f);
    }
    int returnVal = fd.showOpenDialog(Frame.getFrames()[0]);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
            jTextField1.setText(fd.getSelectedFile().getCanonicalPath());
        } catch (IOException ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:28,代码来源:SavePanel.java

示例11: importDiff

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private static void importDiff(VCSContext ctx) {
    final File roots[] = HgUtils.getActionRoots(ctx);
    if (roots == null || roots.length == 0) return;
    final File root = Mercurial.getInstance().getRepositoryRoot(roots[0]);

    final JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(ImportDiffAction.class, "ACSD_ImportBrowseFolder"), null);   // NO I18N
    fileChooser.setDialogTitle(NbBundle.getMessage(ImportDiffAction.class, "ImportBrowse_title"));                                            // NO I18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setApproveButtonMnemonic(NbBundle.getMessage(ImportDiffAction.class, "Import").charAt(0));                      // NO I18N
    fileChooser.setApproveButtonText(NbBundle.getMessage(ImportDiffAction.class, "Import"));                                        // NO I18N
    fileChooser.setCurrentDirectory(new File(HgModuleConfig.getDefault().getImportFolder()));
    JPanel panel = new JPanel();
    final JRadioButton asPatch = new JRadioButton(NbBundle.getMessage(ImportDiffAction.class, "CTL_Import_PatchOption")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(asPatch, asPatch.getText()); // NOI18N
    final JRadioButton asBundle = new JRadioButton(NbBundle.getMessage(ImportDiffAction.class, "CTL_Import_BundleOption")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(asBundle, asBundle.getText()); // NOI18N
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(asBundle);
    buttonGroup.add(asPatch);
    asPatch.setSelected(true);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(asPatch);
    panel.add(asBundle);
    fileChooser.setAccessory(panel);

    DialogDescriptor dd = new DialogDescriptor(fileChooser, NbBundle.getMessage(ImportDiffAction.class, "ImportBrowse_title"));              // NO I18N
    dd.setOptions(new Object[0]);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    fileChooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                final File patchFile = fileChooser.getSelectedFile();

                HgModuleConfig.getDefault().setImportFolder(patchFile.getParent());
                RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root);
                ImportDiffProgressSupport.Kind kind;
                if (asBundle.isSelected()) {
                    kind = ImportDiffProgressSupport.Kind.BUNDLE;
                } else if (asPatch.isSelected()) {
                    kind = ImportDiffProgressSupport.Kind.PATCH;
                } else {
                    kind = null;
                }
                HgProgressSupport support = new ImportDiffProgressSupport(root, patchFile, true, kind);
                support.start(rp, root, org.openide.util.NbBundle.getMessage(ImportDiffAction.class, "LBL_ImportDiff_Progress")); // NOI18N
            }
            dialog.dispose();
        }
    });
    dialog.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:55,代码来源:ImportDiffAction.java

示例12: setIconB_actionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
void setIconB_actionPerformed(ActionEvent e) {
    // Fix until Sun's JVM supports more locales...
    UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
    UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
    UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
    UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
    UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
    UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
    UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
    UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
    UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
    UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
    UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));
    UIManager.put("FileChooser.acceptAllFileFilterText", Local.getString("All Files") + " (*.*)");
    
    JFileChooser chooser = new JFileChooser();
    chooser.setPreferredSize(new Dimension(550, 375));
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Choose icon file"));
    //chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setCurrentDirectory(
        new File(net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/mimetypes").getPath()));
    /*if (System.getProperty("os.name").startsWith("Win")) {
        chooser.setFileFilter(new AllFilesFilter(AllFilesFilter.ICO));
        chooser.setCurrentDirectory(new File("C:\\Program Files"));
    }
    else */
    chooser.addChoosableFileFilter(new net.sf.memoranda.ui.htmleditor.filechooser.ImageFilter());
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        try {
            iconLabel.setIcon(new ImageIcon(chooser.getSelectedFile().getPath()));
       }
        catch (Exception ex) {
  //ex.printStackTrace();
 }
        finally {
            iconPath = chooser.getSelectedFile().getPath();
        }

    }
}
 
开发者ID:ser316asu,项目名称:SER316-Aachen,代码行数:43,代码来源:EditTypeDialog.java

示例13: doSaveImagePointsForStereoCalibration

import javax.swing.JFileChooser; //导入方法依赖的package包/类
synchronized public void doSaveImagePointsForStereoCalibration() {
	//allImagePoints.resize(imageCounter)


	JFileChooser j = new JFileChooser();
	j.setCurrentDirectory(new File(dirPath));
	j.setApproveButtonText("Select folder");
	j.setDialogTitle("Select a folder to store calibration XML files");
	j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // let user specify a base filename
	int ret = j.showSaveDialog(null);
	if (ret != JFileChooser.APPROVE_OPTION) {
		return;
	}
	dirPath = j.getSelectedFile().getPath();
	putString("dirPath", dirPath);

	serializeMatVector(dirPath, "allImagePoints", allImagePoints);
	log.info("***********succeed serialisation allImagePoints***********");

	serializeMatVector(dirPath, "allObjectPoints", allObjectPoints);
	log.info("***********succeed serialisation allObjectPoints***********");
	saved = true;
	generateCalibrationString();

	try
	{
		File fac = new File("previousImageCounter.txt");
		if (!fac.exists())
		{
			fac.createNewFile();
		}
		System.out.println("\n----------------------------------");
		System.out.println("The file has been created.");
		System.out.println("------------------------------------");

		FileWriter wr = new FileWriter(fac);

		log.info(Integer.toString(imageCounter));
		wr.write(Integer.toString(imageCounter));

		wr.close();
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}

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

示例14: setIconB_actionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
void setIconB_actionPerformed(ActionEvent e) {
    // Fix until Sun's JVM supports more locales...
    UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
    UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
    UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
    UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
    UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
    UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
    UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
    UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
    UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
    UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
    UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));
    UIManager.put("FileChooser.acceptAllFileFilterText", Local.getString("All Files") + " (*.*)");
    
    JFileChooser chooser = new JFileChooser();
    chooser.setPreferredSize(new Dimension(550, 375));
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Choose icon file"));
    //chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setCurrentDirectory(
        new File(net.sf.memoranda.ui.AppFrame.class.getResource("/ui/icons/mimetypes").getPath()));
    /*if (System.getProperty("os.name").startsWith("Win")) {
        chooser.setFileFilter(new AllFilesFilter(AllFilesFilter.ICO));
        chooser.setCurrentDirectory(new File("C:\\Program Files"));
    }
    else */
    chooser.addChoosableFileFilter(new net.sf.memoranda.ui.htmleditor.filechooser.ImageFilter());
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        try {
            iconLabel.setIcon(new ImageIcon(chooser.getSelectedFile().getPath()));
       }
        catch (Exception ex) {
  //ex.printStackTrace();
 }
        finally {
            iconPath = chooser.getSelectedFile().getPath();
        }

    }
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:43,代码来源:EditTypeDialog.java

示例15: loadState

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public void loadState()
  {
      JFileChooser chooser = new JFileChooser();
      chooser.setCurrentDirectory( new File( "./") );
      if ( chooser.showSaveDialog( null ) != JFileChooser.APPROVE_OPTION ) {
	return;
}

      File file=chooser.getSelectedFile();

      if (file==null) {
	return;
}


      loadState(file);


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


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