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


Java JFileChooser.ERROR_OPTION属性代码示例

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


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

示例1: actionPerformed

@Override
public void actionPerformed(ActionEvent e) {
    JFileChooser chooser = GrooveFileChooser.getInstance();
    int result = chooser.showOpenDialog(SaveLTSAsDialog.this.simulator.getFrame());
    // now load, if so required
    if (result == JFileChooser.APPROVE_OPTION) {
        SaveLTSAsDialog.this.dirField.setText(chooser.getSelectedFile().getAbsolutePath());
    }
    if (result == JFileChooser.CANCEL_OPTION) {
        // System.out.println("Cancelled");
    }
    if (result == JFileChooser.ERROR_OPTION) {
        // System.out.println("Whooops");
    }

}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:16,代码来源:SaveLTSAsDialog.java

示例2: getFile

private File getFile(int reply, JFileChooser chooser, JTextField field, File oldFile)
{
	switch( reply )
	{
		case JFileChooser.ERROR_OPTION: {
			JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(this), "Error retrieving file", "Error",
				JOptionPane.ERROR_MESSAGE);
			field.setText("");
			return null;
		}
		case JFileChooser.APPROVE_OPTION: {
			File file = chooser.getSelectedFile();
			field.setText(file.getPath());
			return file;
		}
		case JFileChooser.CANCEL_OPTION: {
			return oldFile;
		}
	}
	field.setText("");
	return null;
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:ImportPage.java

示例3: loadExcelFile

public void loadExcelFile() {
	type = UnknownDataSet.EXCEL_FILE;
	jfc = haxby.map.MapApp.getFileChooser();
	jfc.setFileFilter(eff);
	int c = jfc.showOpenDialog(this);
	if (c==JFileChooser.CANCEL_OPTION || c == JFileChooser.ERROR_OPTION) {
		// If user cancels then close the dialog box also.
		input = null;
		setVisible(false);
		return;
	}
	path = jfc.getSelectedFile().getPath();
	if(jfc.getSelectedFile().getName().endsWith("xls")){
		loadExcelFile(jfc.getSelectedFile());
	}else if(jfc.getSelectedFile().getName().endsWith("xlsx")){
		loadExcelTypeXLSX(jfc.getSelectedFile());
	}else{
		return;
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:20,代码来源:DBInputDialog.java

示例4: loadModel

/**
 * Shows a Load window and loads chosen model inside specified model data file
 * @param modelData data file where information should be stored. Note that <b>its type
 * must be compatible with defaultFilter chosen in the constructor</b>, otherwise a
 * ClassCastException will be thrown
 * @param parent parent component of loading window
 * @return SUCCESS on success, CANCELLED if loading is cancelled,
 * FAILURE if an error occurs and WARNING is one or more warnings are generated due to
 * format conversion
 * @throws ClassCastException if modelData is not of instance of the correct class
 * @see #getFailureMotivation getFailureMotivation()
 */
public int loadModel(Component parent) {
	warnings.clear();
	int status;
	status = this.showOpenDialog(parent);
	if (status == JFileChooser.CANCEL_OPTION) {
		return CANCELLED;
	} else if (status == JFileChooser.ERROR_OPTION) {
		failureMotivation = "Error selecting input file";
		return FAILURE;
	}

	f = dialog.getSelectedFile();

	try {
		if (defaultFilter == LOG) {

		}

	} catch (Exception e) {
		e.printStackTrace();
		failureMotivation = e.getClass().getName() + ": " + e.getMessage();
		return FAILURE;
	}
	// If no warnings were found, report success
	if (warnings.size() > 0) {
		return WARNING;
	} else {
		return SUCCESS;
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:42,代码来源:Loader.java

示例5: saveModel

/**
 * Saves specified model into specified file or shows save as window if file is null
 * @param modelData data file where information should be stored. Note that <b>its type
 * must be compatible with defaultFilter chosen in the constructor</b>, otherwise a
 * ClassCastException will be thrown
 * @param parent parent window that will own the save as dialog
 * @param file location where pecified model must be saved or null if save as must be shown
 * @return SUCCESS on success, CANCELLED if loading is cancelled,
 * FAILURE if an error occurs
 * @throws ClassCastException if modelData is not of instance of the correct class
 * @see #getFailureMotivation getFailureMotivation()
 */
public int saveModel(Object modelData, Component parent, File file) {
	if (file == null) {
		// Shows save as window
		int status;
		status = this.showSaveDialog(parent);
		if (status == JFileChooser.CANCEL_OPTION) {
			return CANCELLED;
		} else if (status == JFileChooser.ERROR_OPTION) {
			failureMotivation = "Error selecting output file";
			return FAILURE;
		}
		file = dialog.getSelectedFile();
	} else
	// Check extension to avoid saving over a converted file
	if (!file.getName().endsWith(defaultFilter.getFirstExtension())) {
		int resultValue = JOptionPane.showConfirmDialog(parent, "<html>File <font color=#0000ff>" + file.getName() + "</font> does not have \""
				+ defaultFilter.getFirstExtension() + "\" extension.<br>Do you want to replace it anyway?</html>", "JMT - Warning",
				JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
		if (resultValue != JOptionPane.OK_OPTION) {
			return CANCELLED;
		}
	}

	// Now checks to save correct type of model
	try {
		if (defaultFilter == JMODEL || defaultFilter == JSIM) {
			XMLArchiver.saveModel(file, (CommonModel) modelData);
		} else if (defaultFilter == JMVA) {
			xmlutils.saveXML(((ExactModel) modelData).createDocument(), file);
		} else if (defaultFilter == JABA) {
			xmlutils.saveXML(((JabaModel) modelData).createDocument(), file);
		}
	} catch (Exception e) {
		failureMotivation = e.getClass().getName() + ": " + e.getMessage();
		return FAILURE;
	}
	return SUCCESS;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:50,代码来源:ModelLoader.java

示例6: getFileToOpen

private String getFileToOpen() {
  JFileChooser projectFC = new JFileChooser(browserPath);
  int validPath = projectFC.showOpenDialog(myCP);
  if (validPath == JFileChooser.ERROR_OPTION || validPath == JFileChooser.CANCEL_OPTION) {
    return null;
  } else {
    return projectFC.getSelectedFile().toString();
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:9,代码来源:AIMerger.java

示例7: getFileToOpen

private String getFileToOpen() {
  JFileChooser projectFC = new JFileChooser();
  int validPath = projectFC.showOpenDialog(myCP);
  if (validPath == JFileChooser.ERROR_OPTION || validPath == JFileChooser.CANCEL_OPTION) {
    return null;
  } else {
    return projectFC.getSelectedFile().toString();
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:9,代码来源:AIMerger.java

示例8: exportExcel

public void exportExcel() {
	JFileChooser jfc = new JFileChooser(System.getProperty("user.dir"));
	ExcelFileFilter eff = new ExcelFileFilter();
	jfc.setFileFilter(eff);
	File f=new File("dsdpTable.xls");
	jfc.setSelectedFile(f);
	do {
		int c = jfc.showSaveDialog(null);
		if (c==JFileChooser.CANCEL_OPTION||c==JFileChooser.ERROR_OPTION) return;
		f = jfc.getSelectedFile();
		if (f.exists()) {
			c=JOptionPane.showConfirmDialog(null, "File Already Exists\nConfirm Overwrite");
			if (c==JOptionPane.OK_OPTION) break;
			if (c==JOptionPane.CANCEL_OPTION) return;
		}
	} while (f.exists());

	try {
		WritableWorkbook wb = Workbook.createWorkbook(f);
		WritableSheet sheet = wb.createSheet("First Sheet", 0);
		for (int i=0;i<table.getColumnCount();i++)
			sheet.addCell( new Label(i,0,table.getColumnName(i)) );
		for (int i=0;i<table.getRowCount();i++) {
			for (int j=0; j<table.getColumnCount();j++) {
				Object o = table.getValueAt(i, j);
				if (o == null || ( o instanceof String && ((String)o).equals("NaN") ) ) o = "";
				sheet.addCell( new Label(j,i+1,o.toString()) );
			}
		}
		wb.write();
		wb.close();
	} catch (Exception ex){
		ex.printStackTrace();
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:35,代码来源:DSDPDemo.java

示例9: exportASCII

public void exportASCII() {
	JFileChooser jfc = new JFileChooser(System.getProperty("user.dir"));
	File f=new File(graphDialog.getTitle()+"_age_depth.txt");
	jfc.setSelectedFile(f);
	do {
		int c = jfc.showSaveDialog(null);
		if (c==JFileChooser.CANCEL_OPTION||c==JFileChooser.ERROR_OPTION) return;
		f = jfc.getSelectedFile();
		if (f.exists()) {
			c=JOptionPane.showConfirmDialog(null, "File Already Exists\nConfirm Overwrite");
			if (c==JOptionPane.OK_OPTION) break;
			if (c==JOptionPane.CANCEL_OPTION) return;
		}
	} while (f.exists());

	try {
		BufferedWriter out = new BufferedWriter(new FileWriter(f));
		out.write("ID\tdepth\tage\tsource\n");
		float[] firstTie = (float[])ties.get(0);
		String sourceString = (String)holeSources.get(0);
		out.write(graphDialog.getTitle() + "\t" + firstTie[0] + "\t" + firstTie[1] + "\t" + sourceString + "\n");
		for( int i=0 ; i<ties.size() ; i++) {
			float[] tie = (float[])ties.get(i);
			out.write("\t" + tie[0] + "\t" + tie[1] + "\t\n");
		}
		out.close();
	} catch (IOException ex){

	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:30,代码来源:AgeDepthModel.java

示例10: loadFile

public void loadFile(){
	type = UnknownDataSet.ASCII_FILE;
	jfc.setFileFilter(null);
	int c = jfc.showOpenDialog(this);
	if (c==JFileChooser.CANCEL_OPTION || c == JFileChooser.ERROR_OPTION) return;
	path = jfc.getSelectedFile().getPath();
	loadFile(jfc.getSelectedFile());
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:8,代码来源:OtherDBInputDialog.java

示例11: loadExcelFile

public void loadExcelFile() {
	type = UnknownDataSet.EXCEL_FILE;
	jfc.setFileFilter(eff);
	int c = jfc.showOpenDialog(this);
	if (c==JFileChooser.CANCEL_OPTION || c == JFileChooser.ERROR_OPTION) return;
	path = jfc.getSelectedFile().getPath();
	loadExcelFile(jfc.getSelectedFile());
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:8,代码来源:OtherDBInputDialog.java

示例12: loadFile

public void loadFile(){
	type = UnknownDataSet.ASCII_FILE;
	jfc = haxby.map.MapApp.getFileChooser();
	jfc.setFileFilter(null);
	int c = jfc.showOpenDialog(this);
	if (c==JFileChooser.CANCEL_OPTION || c == JFileChooser.ERROR_OPTION) {
		return;
	}
	path = jfc.getSelectedFile().getPath();
	loadFile(jfc.getSelectedFile());
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:11,代码来源:DBInputDialog.java

示例13: exportASCII

public void exportASCII(String saveOption){
	//run standard checks before exporting
	if (!exportChecks(saveOption)) return;
	
	JFileChooser jfc = new JFileChooser(System.getProperty("user.home"));
	File f=new File(desc.name.replace(":", "")+".txt");
	jfc.setSelectedFile(f);
	do {
		int c = jfc.showSaveDialog(null);
		if (c==JFileChooser.CANCEL_OPTION||c==JFileChooser.ERROR_OPTION) return;
		f = jfc.getSelectedFile();
		if (f.exists()) {
			c=JOptionPane.showConfirmDialog(null, "File Already Exists\nConfirm Overwrite");
			if (c==JOptionPane.OK_OPTION) break;
			if (c==JOptionPane.CANCEL_OPTION) return;
		}
	} while (f.exists());

	try {
		BufferedWriter out = new BufferedWriter(new FileWriter(f));
		//don't include Plot column
		for (int i=1;i<dataT.getColumnCount();i++)
			out.write(dataT.getColumnName(i)+"\t");
		out.write("\n");
		
		int[] ind;
		if (saveOption.equals("selection")) {
			ind = dataT.getSelectedRows();
		} else if (saveOption.equals("plottable")) {
			ind = getPlottableRows();
		} else {
			ind = new int[dataT.getRowCount()];
			for (int i=0; i<dataT.getRowCount(); i++) ind[i] = i;
		}
			
		for (int i=0;i<ind.length;i++) {
			for (int j=1; j<dataT.getColumnCount();j++) {
				Object o = dataT.getValueAt(ind[i], j);
				if (o instanceof String && ((String)o).equals("NaN")) o = "";
				out.write(o+"\t");
			}
			out.write("\n");
		}
		out.close();
	} catch (IOException ex){

	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:48,代码来源:UnknownDataSet.java

示例14: exportSelectExcel

public void exportSelectExcel(){
	if (table.getSelectedRowCount() == 0) {
		JOptionPane.showMessageDialog(null, "No data selected for export", "No Selection", JOptionPane.ERROR_MESSAGE);
		return;
	}

	JFileChooser jfc = new JFileChooser(System.getProperty("user.dir"));
	ExcelFileFilter eff = new ExcelFileFilter();
	jfc.setFileFilter(eff);
	File f=new File("dsdpTableSelection.xls");
	jfc.setSelectedFile(f);
	do {
		int c = jfc.showSaveDialog(null);
		if (c==JFileChooser.CANCEL_OPTION||c==JFileChooser.ERROR_OPTION) return;
		f = jfc.getSelectedFile();
		if (f.exists()) {
			c=JOptionPane.showConfirmDialog(null, "File Already Exists\nConfirm Overwrite");
			if (c==JOptionPane.OK_OPTION) break;
			if (c==JOptionPane.CANCEL_OPTION) return;
		}
	} while (f.exists());

	try {
		WritableWorkbook wb = Workbook.createWorkbook(f);
		WritableSheet sheet = wb.createSheet("First Sheet", 0);
		for (int i=0;i<table.getColumnCount();i++)
			sheet.addCell( new Label(i,0,table.getColumnName(i)) );
		int sel[] = table.getSelectedRows();
		for (int i=0;i<sel.length;i++) {
			for (int j=0; j<table.getColumnCount();j++) {
				Object o = table.getValueAt(sel[i], j);
				if (o == null || ( o instanceof String && ((String)o).equals("NaN") ) ) o = "";
				sheet.addCell( new Label(j,i+1,o.toString()) );
			}
		}
		wb.write();
		wb.close();
	} catch (Exception ex){
		ex.printStackTrace();
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:41,代码来源:DSDPDemo.java

示例15: saveToFile

private void saveToFile() {

		JFileChooser jfc = new JFileChooser(System.getProperty("user.home"));
		File f=new File("SurveyLines.txt");
		jfc.setSelectedFile(f);
		do {
			int c = jfc.showSaveDialog(null);
			if (c==JFileChooser.CANCEL_OPTION||c==JFileChooser.ERROR_OPTION) return;
			f = jfc.getSelectedFile();
			if (f.exists()) {
				c=JOptionPane.showConfirmDialog(null, "File Already Exists\nConfirm Overwrite");
				if (c==JOptionPane.OK_OPTION) break;
				if (c==JOptionPane.CANCEL_OPTION) return;
			}
		} while (f.exists());

		try {
			BufferedWriter out = new BufferedWriter(new FileWriter(f));
			
			//add disclaimer at the top of the output file
			out.write("NOT TO BE USED FOR NAVIGATION PURPOSES\n");
			boolean firstCol = true;
			for (int i=0;i<tm.getColumnCount();i++) {
				if (i == sp.getSurveyLineColumn()) continue;
				if (firstCol) {
					out.write(tm.getColumnName(i));
					firstCol = false;
				} else {
					out.write("," + tm.getColumnName(i));
				}
			}
			out.write("\n");
			
			int[] ind;
			ind = new int[tm.getRowCount()];
			for (int i=0; i<tm.getRowCount(); i++) ind[i] = i;
			
			for (int i=0;i<tm.getRowCount();i++) {
				firstCol = true;
				for (int j=0; j<tm.getColumnCount();j++) {
					if (j == sp.getSurveyLineColumn()) continue;
					Object o = tm.getValueAt(i, j);
					if (o instanceof String && ((String)o).equals("NaN")) o = "";
					if (firstCol) {
						out.write(o.toString());
						firstCol = false;
					} else {
						out.write(","+ o);
					}
				}
				out.write("\n");
			}
			out.close();
		} catch (IOException e){
			JOptionPane.showMessageDialog(panel, "Unable to save file", "Save Error", JOptionPane.ERROR_MESSAGE);
			System.out.println(e);
		}
	}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:58,代码来源:SurveyPlannerDataDisplay.java


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