本文整理汇总了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;
}
示例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();
}
}
示例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
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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 + "'");
}
}
}
}
示例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());
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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;
}
示例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;
}
}
示例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();
}
}
示例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();
}
}