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


Java JFileChooser.setDialogType方法代码示例

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


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

示例1: ConstantBackground

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Load the background image by a file selection dialog
 * @param camera camera settings
 */
public ConstantBackground(Camera camera) {
    // initialize array with zeros
    pixels = new float[camera.res_x][camera.res_y];
    zeroPixels();
    
    // choose file
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("background.tif"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("TIF image","tif"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        throw new RuntimeException("Background image not selected");
    }
    File tif_file = fc.getSelectedFile();
    // load the file
    loadFile(tif_file);
    
    // verify that the image is larger or equal to camera resolution
    verifyDimensions(camera, pixels);
}
 
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:29,代码来源:ConstantBackground.java

示例2: onBrowse

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void onBrowse() {
    String path = settingsPanel.txtIdentityFile.getText();
    if (path.isEmpty()) {
        path = getDefaultIdentityFilePath();
    }
    File file = new File(path);
    JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(RemoteRepositoryPanel.class, "RepositoryPanel.IdentityFile.FileChooser.Descritpion"), //NOI18N
            path.isEmpty() ? null : file.getParentFile());
    if (!path.isEmpty()) {
        fileChooser.setSelectedFile(file);
    }
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setDialogTitle(NbBundle.getMessage(RemoteRepositoryPanel.class, "RepositoryPanel.IdentityFile.FileChooser.Title")); //NOI18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    if (JFileChooser.APPROVE_OPTION == fileChooser.showDialog(panel, null)) {
        File f = fileChooser.getSelectedFile();
        settingsPanel.txtIdentityFile.setText(f.getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:RemoteRepository.java

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

示例4: createFileChooser

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private static JFileChooser createFileChooser() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setDialogTitle(Bundle.ExportSnapshotAction_FileChooserCaption());
    fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
    fileChooser.setApproveButtonText(Bundle.ExportSnapshotAction_ExportButtonText());
    fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
    fileChooser.addChoosableFileFilter(new FileFilter() {
        public boolean accept(File f) {
            return f.isDirectory() || f.getName().toLowerCase().endsWith(NPSS_EXT);
        }
        public String getDescription() {
            return Bundle.ExportSnapshotAction_NpssFileFilter(NPSS_EXT);
        }
    });
    return fileChooser;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ExportSnapshotAction.java

示例5: SaveDialog

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Creates a dialog to choose a file to load.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param directory The directory to display when choosing the file.
 * @param fileFilters The available file filters in the dialog.
 * @param defaultName Name of the default save game file.
 */
public SaveDialog(FreeColClient freeColClient, JFrame frame,
        File directory, FileFilter[] fileFilters, String defaultName) {
    super(freeColClient, frame);

    final JFileChooser fileChooser = new JFileChooser(directory);
    if (fileFilters.length > 0) {
        for (FileFilter fileFilter : fileFilters) {
            fileChooser.addChoosableFileFilter(fileFilter);
        }
        fileChooser.setFileFilter(fileFilters[0]);
        fileChooser.setAcceptAllFileFilterUsed(false);
    }
    fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    fileChooser.setSelectedFile(new File(defaultName));
    fileChooser.addActionListener((ActionEvent ae) ->
            setValue((JFileChooser.APPROVE_SELECTION
                    .equals(ae.getActionCommand()))
                ? fileChooser.getSelectedFile() : cancelFile));
    
    List<ChoiceItem<File>> c = choices();
    initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:34,代码来源:SaveDialog.java

示例6: savePositionsActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void savePositionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_savePositionsActionPerformed
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.SAVE_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("emitter_positions.csv"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("CSV file","csv"));
    returnVal = fc.showSaveDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    File positionsCSVFile = fc.getSelectedFile();
    String filename = positionsCSVFile.getAbsolutePath();
    try {
        app.getPositionLogger().setFilename(filename);
        app.getPositionLogger().saveLogFile();
    } catch (IOException ex) {
        IJ.error("Could not save file: " + filename);
    }
}
 
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:22,代码来源:GUI.java

示例7: getFileChooser

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private JFileChooser getFileChooser() {
    if (fileChooser == null) {
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        chooser.setMultiSelectionEnabled(false);
        chooser.setDialogType(JFileChooser.OPEN_DIALOG);
        chooser.setDialogTitle(Bundle.LoadGeneratorCustomizer_ChooseScriptDialogCaption());

        chooser.setFileFilter(new FileFilter() {
                private Set<String> extensions = new HashSet<String>();

                {
                    LoadGenPlugin lg = Lookup.getDefault().lookup(LoadGenPlugin.class);
                    extensions = lg.getSupportedExtensions();
                }

                public boolean accept(File f) {
                    return f.isDirectory() || extensions.contains(FileUtil.getExtension(f.getPath()));
                }

                public String getDescription() {
                    return Bundle.LoadGeneratorCustomizer_SupportedFiles();
                }
            });

        fileChooser = chooser;
    }

    return fileChooser;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:LoadGeneratorCustomizer.java

示例8: getFileChooser

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private JFileChooser getFileChooser() {
    if (fileChooser == null) {
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setMultiSelectionEnabled(false);
        chooser.setDialogType(JFileChooser.OPEN_DIALOG);
        chooser.setDialogTitle(Bundle.SnapshotCustomizer_SelectSnapshotDialogCaption());
        fileChooser = chooser;
    }

    return fileChooser;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:SnapshotCustomizer.java

示例9: emittersChooseFileActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void emittersChooseFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emittersChooseFileActionPerformed
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename
    fc.setSelectedFile(new File("emitters.csv"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("CSV file","csv"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    emittersCsvFile = fc.getSelectedFile();
    //emitter_file_label.setText(emittersCsvFile.getName());
}
 
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:16,代码来源:InitializeSimulation.java

示例10: getFileFromDialog

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private static File getFileFromDialog() {
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("emitters.csv"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("CSV file","csv"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        throw new RuntimeException("You need to select an emitter file!");
    }
    return fc.getSelectedFile();
}
 
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:15,代码来源:FluorophoreReceiver.java

示例11: createAndShowGUI

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private static void createAndShowGUI() {
    fileChooser = new JFileChooser();
    fileChooser.setAcceptAllFileFilterUsed(true);
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);

    FileFilter txtFilter = new FileNameExtensionFilter("Text files", "txt");
    fileChooser.addChoosableFileFilter(txtFilter);
    fileChooser.setFileFilter(txtFilter);
    fileChooser.showOpenDialog(null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:SelectAllFilesFilterTest.java

示例12: initializeComponents

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public void initializeComponents() {
	widthSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 99999, 100));
	heightSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 99999, 100));
	frameDelayLabel = new JLabel("Frame delay (ms):");
	frameDelaySpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99999, 1));

	chooser	= new JFileChooser();
	chooser.setDialogType(JFileChooser.SAVE_DIALOG);
	chooser.setAcceptAllFileFilterUsed(false);
	//setAnimationMode(true);
	//		chooser.setSelectedFile(StringUtil.resolveConflictName(chooser.getSelectedFile(), "glitch", true));
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:13,代码来源:SaveFrame.java

示例13: setUseRidgeRegression

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public void setUseRidgeRegression(boolean useRidgeRegression) {
	if (useRidgeRegression) {
		if (freqBins == null) {
			freqBins = new ITDBins[64];
			for (int i = 0; i < 64; i++) {
				freqBins[i] = new ITDBins(averagingDecay * 1000000, 1, maxITD, numOfBins);
			}
		}
		JFileChooser fc = new JFileChooser();
		fc.setDialogType(JFileChooser.SAVE_DIALOG);
		int state = fc.showSaveDialog(null);
		if (state == JFileChooser.APPROVE_OPTION) {
			String path = fc.getSelectedFile().getPath();
			try {

				File file = new File(path);
				BufferedReader bufRdr = new BufferedReader(new FileReader(file));
				ridgeWeights = new double[65];
				for (int i = 0; i < 65; i++) {
					ridgeWeights[i] = Double.parseDouble(bufRdr.readLine());
				}
				bufRdr.close();
			} catch (IOException ex) {
				log.warning("while loading weights, caught exception " + ex);
				ex.printStackTrace();
			}
		}
	}
	getPrefs().putBoolean("ITDFilter.useRidgeRegression", useRidgeRegression);
	getSupport().firePropertyChange("useRidgeRegression", this.useRidgeRegression, useRidgeRegression);
	this.useRidgeRegression = useRidgeRegression;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:33,代码来源:ITDFilter.java

示例14: LoadDialog

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Creates a dialog to choose a file to load.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param directory The directory to display when choosing the file.
 * @param fileFilters The available file filters in the dialog.
 */
public LoadDialog(FreeColClient freeColClient, JFrame frame,
        File directory, FileFilter[] fileFilters) {
    super(freeColClient, frame);

    final JFileChooser fileChooser = new JFileChooser(directory);
    if (fileFilters.length > 0) {
        for (FileFilter fileFilter : fileFilters) {
            fileChooser.addChoosableFileFilter(fileFilter);
        }
        fileChooser.setFileFilter(fileFilters[0]);
        fileChooser.setAcceptAllFileFilterUsed(false);
    }
    fileChooser.setControlButtonsAreShown(true);
    fileChooser.setApproveButtonText(Messages.message("ok"));
    //fileChooser.setCancelButtonText(Messages.message("cancel"));
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    fileChooser.addActionListener((ActionEvent ae) -> {
            final String cmd = ae.getActionCommand();
            File value = (JFileChooser.APPROVE_SELECTION.equals(cmd))
                ? ((JFileChooser)ae.getSource()).getSelectedFile()
                : cancelFile;
            setValue(value);
        });

    List<ChoiceItem<File>> c = choices();
    initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:38,代码来源:LoadDialog.java

示例15: backgroundChooseFileActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void backgroundChooseFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backgroundChooseFileActionPerformed
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("background.tif"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("Tif file","tif"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    backgroundTifFile = fc.getSelectedFile();
    // background_file_label.setText(backgroundTifFile.getName());
}
 
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:16,代码来源:InitializeSimulation.java


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