List of usage examples for javax.swing JOptionPane DEFAULT_OPTION
int DEFAULT_OPTION
To view the source code for javax.swing JOptionPane DEFAULT_OPTION.
Click Source Link
JOptionPane
. From source file:Main.java
public static void errorMessage(Exception exceptionMsg, boolean quiet) { /**// w ww .j av a2 s. c o m * Display Jpanel Error messages any SQL Errors. Overloads * errorMessage(String e) */ Object[] options = { "OK", }; JOptionPane.showOptionDialog(null, exceptionMsg, messagerHeader, JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); if (!quiet) { exceptionMsg.printStackTrace(); } // DatabaseManagerSwing.StatusMessage(READY_STATUS); }
From source file:com.willwinder.universalgcodesender.utils.GUIHelpers.java
/** * Displays an error message to the user. * @param errorMessage message to display in the dialog. * @param modal toggle whether the message should block or fire and forget. *//*from w ww. j a v a 2s. c o m*/ public static void displayErrorDialog(final String errorMessage, boolean modal) { if (StringUtils.isEmpty(errorMessage)) { LOGGER.warning("Something tried to display an error message with an empty message: " + ExceptionUtils.getStackTrace(new Throwable())); return; } Runnable r = () -> { //JOptionPane.showMessageDialog(new JFrame(), errorMessage, // Localization.getString("error"), JOptionPane.ERROR_MESSAGE); NarrowOptionPane.showNarrowDialog(250, errorMessage.replaceAll("\\.\\.", "\\."), Localization.getString("error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); }; if (modal) { r.run(); } else { java.awt.EventQueue.invokeLater(r); } }
From source file:com.willwinder.universalgcodesender.utils.GUIHelpers.java
public static void displayHelpDialog(final String helpMessage) { java.awt.EventQueue.invokeLater(() -> { NarrowOptionPane.showNarrowConfirmDialog(250, helpMessage, Localization.getString("help"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); //JOptionPane.showMessageDialog(new JFrame(), helpMessage, // Localization.getString("help"), JOptionPane.INFORMATION_MESSAGE); });/*from ww w . j a v a 2 s. c o m*/ }
From source file:com.moneydance.modules.features.importlist.io.DeleteOneOperation.java
@Override public void showWarningAndExecute(final List<File> files) { final File file = files.iterator().next(); final String message = this.localizable.getConfirmationMessageDeleteOneFile(file.getName()); final Object confirmationLabel = new JLabel(message); final Image image = Helper.INSTANCE.getSettings().getIconImage(); Icon icon = null;/*from w w w . jav a 2 s .c o m*/ if (image != null) { icon = new ImageIcon(image); } final Object[] options = { this.localizable.getOptionDeleteFile(), this.localizable.getOptionCancel() }; final int choice = JOptionPane.showOptionDialog(null, // no parent component confirmationLabel, null, // no title JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, icon, options, options[1]); if (choice == 0) { this.execute(files); } else { LOG.info(String.format("Canceled deleting file %s", file.getAbsoluteFile())); } }
From source file:hr.fer.zemris.vhdllab.platform.gui.dialog.AbstractOptionPaneDialogManager.java
private Object[] getOptionsForType(int optionType) { switch (optionType) { case JOptionPane.DEFAULT_OPTION: return getOption("ok"); case JOptionPane.YES_NO_CANCEL_OPTION: return getOption("yes", "no", "cancel"); case JOptionPane.YES_NO_OPTION: return getOption("yes", "no"); case JOptionPane.OK_CANCEL_OPTION: return getOption("ok", "cancel"); default:/* w w w . j a v a2s . c o m*/ throw new IllegalStateException("Unknown option: " + optionType); } }
From source file:javaapplication3.SolidscapeDialog.java
public void SolidscapeDialogStart() { instance = new InstanceCall(); setTitle("Add Information about" + new File(BPath.getText()).getName()); hideErrorFields();/*from www .j a v a 2s . co m*/ Date date = Calendar.getInstance().getTime(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); this.dateRunTxt.setText(sdf.format(date)); this.setLocationRelativeTo(null); //search database for buildName //File BPathfile = new File(BPath.getText().replace("\\", "\\\\")); setVisible(true); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { String ObjButtons[] = { "Yes", "No" }; int PromptResult = JOptionPane.showOptionDialog(null, "Save as an Open Build?", "Save", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]); if (PromptResult == JOptionPane.YES_OPTION) { gatherScrapThenExit(); PrinterBuild.selectAllFiles("Solidscape"); dispose(); } else { ResultSet r = SolidscapeMain.dba.searchPendingByBuildName(new File(BPath.getText()).getName()); try { while (r.next()) { SolidscapeMain.dba.updatePendingJobsBuildName(r.getString("buildName"), r.getString("fileName")); } } catch (SQLException ex) { Logger.getLogger(SolidscapeDialog.class.getName()).log(Level.SEVERE, null, ex); } ResultSet s = SolidscapeMain.dba .searchSolidscapeByBuildName(new File(BPath.getText()).getName()); try { while (s.next()) { SolidscapeMain.dba.deleteByBuildName(s.getString("buildName"), "solidscape"); } } catch (SQLException ex) { Logger.getLogger(SolidscapeDialog.class.getName()).log(Level.SEVERE, null, ex); } dispose(); } } }); }
From source file:javaapplication3.ObjetDialog.java
public void ObjetDialogStart() { instance = new InstanceCall(); setTitle("Add Information about" + new File(BPath.getText()).getName()); hideErrorFields();// ww w . j a va 2s .c o m Date date = Calendar.getInstance().getTime(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); this.dateRunTxt.setText(sdf.format(date)); this.setLocationRelativeTo(null); //search database for buildName //File BPathfile = new File(BPath.getText().replace("\\", "\\\\")); setVisible(true); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { String ObjButtons[] = { "Yes", "No" }; int PromptResult = JOptionPane.showOptionDialog(null, "Save as an Open Build?", "Save", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]); if (PromptResult == JOptionPane.YES_OPTION) { gatherScrapThenExit(); PrinterBuild.selectAllFiles("Objet"); dispose(); } else { ResultSet r = ObjetMain.dba.searchPendingByBuildName(new File(BPath.getText()).getName()); try { while (r.next()) { ObjetMain.dba.updatePendingJobsBuildName(r.getString("buildName"), r.getString("fileName")); } } catch (SQLException ex) { Logger.getLogger(ObjetDialog.class.getName()).log(Level.SEVERE, null, ex); } ResultSet s = ObjetMain.dba.searchObjetByBuildName(new File(BPath.getText()).getName()); try { while (s.next()) { ObjetMain.dba.deleteByBuildName(s.getString("buildName"), "objet"); } } catch (SQLException ex) { Logger.getLogger(ObjetDialog.class.getName()).log(Level.SEVERE, null, ex); } dispose(); } } }); }
From source file:javaapplication3.ZCorpDialog.java
public void ZCorpDialogStart() { instance = new InstanceCall(); setTitle("Add Information about" + new File(BPath.getText()).getName()); hideErrorFields();//from w w w. j ava2 s . c om Date date = Calendar.getInstance().getTime(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); this.dateRunTxt.setText(sdf.format(date)); this.setLocationRelativeTo(null); //search database for buildName //File BPathfile = new File(BPath.getText().replace("\\", "\\\\")); setVisible(true); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { String ObjButtons[] = { "Yes", "No" }; int PromptResult = JOptionPane.showOptionDialog(null, "Save as an Open Build?", "Save", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]); if (PromptResult == JOptionPane.YES_OPTION) { gatherScrapThenExit(); PrinterBuild.selectAllFiles("ZCorp"); dispose(); } else { ResultSet r = ZCorpMain.dba.searchPendingByBuildName(new File(BPath.getText()).getName()); try { while (r.next()) { ZCorpMain.dba.updatePendingJobsBuildName(r.getString("buildName"), r.getString("fileName")); } } catch (SQLException ex) { Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex); } ResultSet s = ZCorpMain.dba.searchZCorpByBuildName(new File(BPath.getText()).getName()); try { while (s.next()) { ZCorpMain.dba.deleteByBuildName(s.getString("buildName"), "zcorp"); } } catch (SQLException ex) { Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex); } dispose(); } } }); }
From source file:hr.fer.zemris.vhdllab.platform.ui.command.DevFloodWithCompliationRequestsCommand.java
private void showResults(List<String> results) { logger.info(results);/*from w w w . j a v a2s . c o m*/ JList list = new JList(results.toArray()); JOptionPane.showOptionDialog(null, new JScrollPane(list), "Results", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); }
From source file:com.ln.gui.Main.java
public void swingupd() { EventQueue.invokeLater(new Runnable() { public void run() { try { String av = "Updates available!"; JOptionPane pane1 = new JOptionPane(av, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); Updatechecker upd = new Updatechecker(); upd.setVisible(true);/*from w ww.ja va 2s . com*/ upd.setLocationRelativeTo(rootPane); upd.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } catch (Exception e) { } } }); }