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


Java JOptionPane.showConfirmDialog方法代码示例

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


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

示例1: saveOrDiscardLastResults

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public static boolean saveOrDiscardLastResults() {
    if (lastResults != null) {
        int ret = JOptionPane.showConfirmDialog
            (guiFrame,
             "The results of the last test will be "+
             "discarded if you continue!  Do you want "+
             "to save them?",
             "Discard last results?",
             JOptionPane.YES_NO_CANCEL_OPTION);
        if (ret == JOptionPane.CANCEL_OPTION) {
            return false;
        } else if (ret == JOptionPane.YES_OPTION) {
            if (saveResults()) {
                lastResults = null;
            } else {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:J2DBench.java

示例2: actionPerformed

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e){
	Object eventSource = e.getSource(); 
	if (eventSource == parent.yieldType){
		parent.set_yield_type();
		parent.compute();
	}
	if (eventSource == parent.impliedButton){
		parent.toggle_implied();
		parent.compute();
	}
	if (eventSource == parent.closeButton){
		JOptionPane.showConfirmDialog(null, 
			"The Black Scholes Calculator was written by Prof. Jayanth R. Varma (http://www.iima.ac.in/~jrvarma/)\n" +
	        "and is released under the GNU General Public Licence. \n\n" +
	        "The implied volatility is calculated using the UnivariateRealSolver from the Apache Commons \n" +
	        "Mathematics Library (http://commons.apache.org/math/) which is released under the Apache Licence\n" +
	        "by the Apache Software Foundation.", 
	        "Black Scholes Calculator Exiting...", 
	        JOptionPane.PLAIN_MESSAGE);
		System.exit(0);
	}
	if (eventSource == parent.rateType){
    	parent.compute();
	}
}
 
开发者ID:jrvarma,项目名称:black-scholes-java,代码行数:26,代码来源:GBSEngine.java

示例3: showMasterPasswordEntry

import javax.swing.JOptionPane; //导入方法依赖的package包/类
/**
 * Show master password dialog if enabled
 */
private void showMasterPasswordEntry() {
	ConfigIO cfg = ConfigIO.getInstance();
	if (cfg.isMasterPwdEnabled()) {
		JPanel panel = new JPanel(new BorderLayout());
		JPasswordField pf = new JPasswordField();
		panel.setBorder(new EmptyBorder(0, 10, 0, 10));
		panel.add(pf, BorderLayout.NORTH);
		JFrame frame = new JFrame();
		frame.setAlwaysOnTop(true);

		int option = JOptionPane.showConfirmDialog(frame, panel, I18n.get("main.start.requestmasterpwd"),
				JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
		frame.dispose();
		if (option == JOptionPane.OK_OPTION) {
			cfg.setMasterPassword(new String(pf.getPassword()));
		} else {
			// TODO show config dialog
		}
	}
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:24,代码来源:Dropzone.java

示例4: actionPerformed

import javax.swing.JOptionPane; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
	Control c = getSelectedControl();
	if( c != null )
	{
		int confirm = JOptionPane.showConfirmDialog(PowerSearchList.this,
			CurrentLocale.get("com.dytech.edge.admin.wizard.powersearchlist.confirm"), CurrentLocale //$NON-NLS-1$
				.get("com.dytech.edge.admin.wizard.powersearchlist.remove"), //$NON-NLS-1$
			JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

		if( confirm == JOptionPane.YES_OPTION )
		{
			table.clearSelection();
			model.removeControl(c);
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:PowerSearchList.java

示例5: approveSelection

import javax.swing.JOptionPane; //导入方法依赖的package包/类
/**
 * Overrides default method to provide a warning if saving over an existing file
 */
@Override
public void approveSelection() {
	// Gets the choosed file name
	String name = getSelectedFile().getName();
	String parent = getSelectedFile().getParent();
	if (getDialogType() == OPEN_DIALOG) {
		super.approveSelection();
	}
	if (getDialogType() == SAVE_DIALOG) {
		try {
			FileFilter used = ((FileFilter) this.getFileFilter());

			if (!name.toLowerCase().endsWith(used.getExtension())) {
				name = name + used.getExtension();
				setSelectedFile(new File(parent, name));
			}
			if (getSelectedFile().exists()) {
				int resultValue = JOptionPane.showConfirmDialog(this, "<html>File <font color=#0000ff>" + name
						+ "</font> already exists in this folder.<br>Do you want to replace it?</html>", "JMT - Warning",
						JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
				if (resultValue == JOptionPane.OK_OPTION) {
					getSelectedFile().delete();
					super.approveSelection();
				}
			} else {
				super.approveSelection();
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, "Select a type for the output file", "Select a type for the output file",
					JOptionPane.ERROR_MESSAGE);
		}
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:37,代码来源:TextualPanel.java

示例6: jButton_resetAllActionPerformed

import javax.swing.JOptionPane; //导入方法依赖的package包/类
private void jButton_resetAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_resetAllActionPerformed
    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(
            this,
            "Are you sure you want to reset all settings?",
            "Reset All Settings",
            JOptionPane.YES_NO_OPTION)) {
        try {
            appConfigController.resetFromAppConfigFile(true);
            copySettingsToUI();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(
                    this,
                    "Could not reset settings: " + e.getMessage(),
                    "Could Not Reset Settings",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:19,代码来源:AppConfigDialog.java

示例7: deleteTestData

import javax.swing.JOptionPane; //导入方法依赖的package包/类
private void deleteTestData(Object source) {
    JTabbedPane tab = (JTabbedPane) source;
    TestDataTablePanel panel = getSelectedData();
    if (!panel.isGlobalData) {
        int index = tab.getSelectedIndex();
        String name = tab.getTitleAt(index);
        int option = JOptionPane.showConfirmDialog(null, "Are you sure want to delete the TestData [" + name + "]", "Delete TestData", JOptionPane.YES_NO_OPTION);
        if (option == JOptionPane.YES_OPTION) {
            Boolean flag = testDesign.getProject().getTestData()
                    .getTestDataFor(envTab.getTitleAt(envTab.getSelectedIndex()))
                    .deleteTestData(name);
            if (flag) {
                tab.setSelectedIndex(index - 1);
                tab.removeTabAt(index);
            } else {
                Notification.show("Couldn't Delete Testdata - '" + name + "'");
            }
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:21,代码来源:TestDataComponent.java

示例8: jTableEquipmentMouseClicked

import javax.swing.JOptionPane; //导入方法依赖的package包/类
private void jTableEquipmentMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableEquipmentMouseClicked

        tablaequipment = (DefaultTableModel) jTableEquipment.getModel();
        String numero=String.valueOf(tablaequipment.getValueAt(jTableEquipment.getSelectedRow(), 0));
        String prestamo=String.valueOf(tablaequipment.getValueAt(jTableEquipment.getSelectedRow(), 3));
        int opcion = JOptionPane.showConfirmDialog(this, "Va a pagar la multa", TOOL_TIP_TEXT_KEY, WIDTH);
        if(opcion==0){
            if(loanDao.check_prestamo(Integer.parseInt(prestamo))){
               fineDao.deleteFine(numero); 
               fineDao.updateFine(numero);
            }else{
              JOptionPane.showMessageDialog(null,"Por favor hacer devolucion del equipo primero");
            } 
            
        }
        int row = jTableEquipment.rowAtPoint(evt.getPoint());

    }
 
开发者ID:franco026,项目名称:LOSY,代码行数:19,代码来源:Fine.java

示例9: approveSelection

import javax.swing.JOptionPane; //导入方法依赖的package包/类
/**
 * Overrides default method to provide a warning if saving over an existing file
 */
@Override
public void approveSelection() {
	// Gets the choosed file name
	String name = getSelectedFile().getName();
	String parent = getSelectedFile().getParent();
	if (getDialogType() == OPEN_DIALOG) {
		super.approveSelection();
	}
	if (getDialogType() == SAVE_DIALOG) {
		PlotImagesFileFilter used = ((PlotImagesFileFilter) this.getFileFilter());
		if (!name.toLowerCase().endsWith(used.getExtension())) {
			name = name + used.getExtension();
			setSelectedFile(new File(parent, name));
		}
		if (getSelectedFile().exists()) {
			int resultValue = JOptionPane.showConfirmDialog(this, "<html>File <font color=#0000ff>" + name
					+ "</font> already exists in this folder.<br>Do you want to replace it?</html>", "JMT - Warning",
					JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
			if (resultValue == JOptionPane.OK_OPTION) {
				getSelectedFile().delete();
				super.approveSelection();
			}
		} else {
			super.approveSelection();
		}
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:31,代码来源:KMeanScatter.java

示例10: approveSelection

import javax.swing.JOptionPane; //导入方法依赖的package包/类
/**
 * Overrides default method to provide a warning if saving over an existing file
 */
@Override
public void approveSelection() {
	// Gets the choosed file name
	String name = getSelectedFile().getName();
	String parent = getSelectedFile().getParent();
	if (getDialogType() == OPEN_DIALOG) {
		super.approveSelection();
	}
	if (getDialogType() == SAVE_DIALOG) {
		PlotImagesFileFilter used = ((PlotImagesFileFilter) this.getFileFilter());
		if (!name.toLowerCase().endsWith(used.getExtension())) {
			name = name + used.getExtension();
			setSelectedFile(new File(parent, name));
		}
		if (getSelectedFile().exists()) {
			int resultValue = JOptionPane.showConfirmDialog(this, "<html>File <font color=#0000ff>" + name
					+ "</font> already exists in this folder.<br>Do you want to replace it?</html>", "File save - Warning",
					JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
			if (resultValue == JOptionPane.OK_OPTION) {
				getSelectedFile().delete();
				super.approveSelection();
			}
		} else {
			super.approveSelection();
		}
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:31,代码来源:WhatIfPlot.java

示例11: doSaveDialog

import javax.swing.JOptionPane; //导入方法依赖的package包/类
/**
 * Does standard 'ok' clicked checking, and confirms overwrite before
 * executing saver if applicable
 * 
 * @param parent
 * @param title
 * @param filter
 * @param defaultFileName
 * @param saver
 */
public static void doSaveDialog(Component parent, String title, FileFilter filter, String defaultFileName,
	FileWorker saver)
{
	final DialogResult result = doDialog(parent, false, title, filter, true, new File(defaultFileName));
	if( result.isOkayed() )
	{
		boolean writeFile = true;
		final File file = result.getFile();
		if( file.exists() )
		{
			final int result2 = JOptionPane.showConfirmDialog(parent,
				CurrentLocale.get("com.tle.common.gui.confirmoverwrite"), //$NON-NLS-1$
				CurrentLocale.get("com.tle.common.gui.overwrite"), //$NON-NLS-1$
				JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

			if( result2 != JOptionPane.YES_OPTION )
			{
				writeFile = false;
			}
		}

		if( writeFile )
		{
			saver.setFile(file);
			saver.setComponent(parent);
			saver.start();
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:DialogUtils.java

示例12: showContinueDialog

import javax.swing.JOptionPane; //导入方法依赖的package包/类
/**
 * Creates and shows a confirmation dialog for continuing the current
 * edit.
 */
private boolean showContinueDialog(String value) {
    int response = JOptionPane.showConfirmDialog(PropertiesTable.this,
        getContinueQuestion(value),
        null,
        JOptionPane.YES_NO_OPTION);
    return response == JOptionPane.YES_OPTION;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:12,代码来源:PropertiesTable.java

示例13: askOverWrite

import javax.swing.JOptionPane; //导入方法依赖的package包/类
int askOverWrite() {
	JFileChooser chooser = MapApp.getFileChooser();
	int ok = JOptionPane.NO_OPTION;
	while( true ) {
		ok = JOptionPane.showConfirmDialog(dialog,
			"File exists. Overwrite?",
			"Overwrite?",
			JOptionPane.YES_NO_CANCEL_OPTION);
		if( ok!=JOptionPane.NO_OPTION) return ok;
		ok = chooser.showSaveDialog(dialog);
		if( ok==JFileChooser.CANCEL_OPTION ) return JOptionPane.CANCEL_OPTION;
		if( !chooser.getSelectedFile().exists() ) return JOptionPane.YES_OPTION;
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:15,代码来源:GMAProfile.java

示例14: botaoLimparChatActionPerformed

import javax.swing.JOptionPane; //导入方法依赖的package包/类
private void botaoLimparChatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoLimparChatActionPerformed
    int sair = JOptionPane.showConfirmDialog(null, "Deseja limpar o chat?", "Limpar chat", JOptionPane.YES_NO_OPTION);
    if (sair == JOptionPane.YES_OPTION) {
        dao.limparChat();
    }
}
 
开发者ID:lucas-dolsan,项目名称:tcc-rpg,代码行数:7,代码来源:PainelDeControle.java

示例15: exportSelectExcel

import javax.swing.JOptionPane; //导入方法依赖的package包/类
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,代码行数:42,代码来源:DSDPDemo.java


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