Java Code Examples for javax.swing.JOptionPane#ERROR_MESSAGE
The following examples show how to use
javax.swing.JOptionPane#ERROR_MESSAGE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserMessageHelper.java From openAGV with Apache License 2.0 | 6 votes |
private int translateType(Type type) { int jOptionType; switch (type) { case ERROR: jOptionType = JOptionPane.ERROR_MESSAGE; break; case INFO: jOptionType = JOptionPane.INFORMATION_MESSAGE; break; case QUESTION: jOptionType = JOptionPane.YES_NO_OPTION; break; default: jOptionType = JOptionPane.PLAIN_MESSAGE; } return jOptionType; }
Example 2
Source File: UiUtils.java From pgptool with GNU General Public License v3.0 | 6 votes |
/** * @param messageType * one of the JOptionPane ERROR_MESSAGE, INFORMATION_MESSAGE, * WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE */ public static void messageBox(ActionEvent originEvent, String msg, String title, int messageType) { Object content = buildMessageContentDependingOnLength(msg); Component parent = findWindow(originEvent); if (messageType != JOptionPane.ERROR_MESSAGE) { JOptionPane.showMessageDialog(parent, content, title, messageType); return; } Object[] options = { text("action.ok"), text("phrase.saveMsgToFile") }; if ("action.ok".equals(options[0])) { // if app context wasn't started MessageSource wont be available options = new String[] { "OK", "Save message to file" }; } int result = JOptionPane.showOptionDialog(parent, content, title, JOptionPane.YES_NO_OPTION, messageType, null, options, JOptionPane.YES_OPTION); if (result == JOptionPane.YES_OPTION || result == JOptionPane.CLOSED_OPTION) { return; } // Save to file saveMessageToFile(parent, msg); }
Example 3
Source File: OptionDialog.java From Astrosoft with GNU General Public License v2.0 | 5 votes |
public static int showDialog(String message, int messageType){ int optionType = JOptionPane.DEFAULT_OPTION; String title = null; if (messageType == JOptionPane.ERROR_MESSAGE){ title = "Error "; optionType = JOptionPane.DEFAULT_OPTION; }else if (messageType == JOptionPane.QUESTION_MESSAGE){ title = "Confirm "; optionType = JOptionPane.YES_NO_OPTION; } else if (messageType == JOptionPane.INFORMATION_MESSAGE){ title = "Information "; optionType = JOptionPane.DEFAULT_OPTION; } JOptionPane pane = new JOptionPane(message, messageType, optionType); JDialog dialog = pane.createDialog(pane, title); UIUtil.applyOptionPaneBackground(pane,UIConsts.OPTIONPANE_BACKGROUND); dialog.setVisible(true); Object selectedValue = pane.getValue(); if(selectedValue instanceof Integer) { return ((Integer)selectedValue).intValue(); } return JOptionPane.CLOSED_OPTION; }
Example 4
Source File: PointFeatureDatasetViewer.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void actionPerformed(ActionEvent e) { if (pfDataset == null) { return; } if (pfDataset.getFeatureType() != FeatureType.STATION) { Component parentComponent = PointFeatureDatasetViewer.this; Object message = "Currently, only the STATION feature type is supported, not " + pfDataset.getFeatureType(); String title = "Invalid feature type"; int messageType = JOptionPane.ERROR_MESSAGE; JOptionPane.showMessageDialog(parentComponent, message, title, messageType); return; } try { ByteArrayOutputStream outStream = new ByteArrayOutputStream(5000); MarshallingUtil.marshalPointDataset(pfDataset, pfDataset.getDataVariables(), outStream); infoTA.setText(outStream.toString(StandardCharsets.UTF_8.name())); infoTA.gotoTop(); infoWindow.setVisible(true); } catch (IOException | XmlException ex) { StringWriter sw = new StringWriter(5000); ex.printStackTrace(new PrintWriter(sw)); infoTA.setText(sw.toString()); infoTA.gotoTop(); infoWindow.setVisible(true); } }
Example 5
Source File: SwingNotifier.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
private int convert(MESSAGE_TYPE type) { switch(type) { case ERROR : return JOptionPane.ERROR_MESSAGE; case INFO : return JOptionPane.INFORMATION_MESSAGE; case WARNING : return JOptionPane.WARNING_MESSAGE; case NONE : return 0; default: return JOptionPane.INFORMATION_MESSAGE; } }
Example 6
Source File: Messages.java From jclic with GNU General Public License v2.0 | 5 votes |
public int showErrorWarning(Component parent, String key, List<Object> values, Exception ex, String buttons) { if (key == null) { key = ERROR; } List<Object> v = new ArrayList<Object>(); String mainMsg = get(key); System.err.println(mainMsg); v.add(mainMsg); if (values != null) { Iterator it = values.iterator(); while (it.hasNext()) { Object o = it.next(); if (o != null) { v.add(o); System.err.println(o); } } } if (ex != null) { String s = ex.getLocalizedMessage(); if (s != null) { v.add(s); } else { v.add(ex.toString()); } System.err.println(s); ex.printStackTrace(System.err); } NarrowOptionPane pane = new NarrowOptionPane(60, v.toArray(), JOptionPane.ERROR_MESSAGE, JOptionPane.DEFAULT_OPTION, null, parseButtons(buttons)); return getFeedback(parent, pane, get(ERROR)); }
Example 7
Source File: UiUtils.java From pgptool with GNU General Public License v3.0 | 5 votes |
public static void messageBox(ActionEvent originEvent, String messageText, String messageTitle, MessageSeverity messageSeverity) { int messageType = JOptionPane.INFORMATION_MESSAGE; if (messageSeverity == MessageSeverity.ERROR) { messageType = JOptionPane.ERROR_MESSAGE; } else if (messageSeverity == MessageSeverity.WARNING) { messageType = JOptionPane.WARNING_MESSAGE; } else if (messageSeverity == MessageSeverity.INFO) { messageType = JOptionPane.INFORMATION_MESSAGE; } UiUtils.messageBox(originEvent, messageText, messageTitle, messageType); }
Example 8
Source File: MessageDialogs.java From FancyBing with GNU General Public License v3.0 | 5 votes |
public void showError(Component frame, String mainMessage, String optionalMessage, boolean isCritical) { int type; if (isCritical) type = JOptionPane.ERROR_MESSAGE; else type = JOptionPane.PLAIN_MESSAGE; Object[] options = { i18n("LB_CLOSE") }; Object defaultOption = options[0]; show(null, frame, "", mainMessage, optionalMessage, type, JOptionPane.DEFAULT_OPTION, options, defaultOption, -1); }
Example 9
Source File: DialogCallbackHandler.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 10
Source File: UiUtils.java From netbeans with Apache License 2.0 | 4 votes |
public static boolean showMessageDialog( final String message, final String title, final MessageType messageType) { initLAF(); boolean exitInstaller = false; switch (UiMode.getCurrentUiMode()) { case SWING: int intMessageType = JOptionPane.INFORMATION_MESSAGE; LogManager.logIndent("... show message dialog"); LogManager.log("title: "+ title); LogManager.log("message: " + message); if (messageType == MessageType.WARNING) { intMessageType = JOptionPane.WARNING_MESSAGE; } else if (messageType == MessageType.CRITICAL) { intMessageType = JOptionPane.ERROR_MESSAGE; exitInstaller = true; } if (messageType == MessageType.ERROR) { int result = JOptionPane.showOptionDialog(null, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, null, JOptionPane.YES_OPTION); if (result == JOptionPane.NO_OPTION) { exitInstaller = true; LogManager.logUnindent("... user selected: NO"); } else { LogManager.logUnindent("... user selected: YES"); } } else { JOptionPane.showMessageDialog(null, message, title, intMessageType); } LogManager.logUnindent("... dialog closed"); break; case SILENT: LogManager.log(message); System.err.println(message); break; } return exitInstaller; }
Example 11
Source File: DialogCallbackHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 12
Source File: DialogCallbackHandler.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 13
Source File: DialogCallbackHandler.java From JDKSourceCode1.8 with MIT License | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 14
Source File: DialogCallbackHandler.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 15
Source File: DialogCallbackHandler.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 16
Source File: DialogCallbackHandler.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 17
Source File: DialogCallbackHandler.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 18
Source File: DialogCallbackHandler.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 19
Source File: DialogCallbackHandler.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }
Example 20
Source File: DialogCallbackHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { this.callback = callback; int confirmationOptionType = callback.getOptionType(); switch (confirmationOptionType) { case ConfirmationCallback.YES_NO_OPTION: optionType = JOptionPane.YES_NO_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO }; break; case ConfirmationCallback.YES_NO_CANCEL_OPTION: optionType = JOptionPane.YES_NO_CANCEL_OPTION; translations = new int[] { JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.OK_CANCEL_OPTION: optionType = JOptionPane.OK_CANCEL_OPTION; translations = new int[] { JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL }; break; case ConfirmationCallback.UNSPECIFIED_OPTION: options = callback.getOptions(); /* * There's no way to know if the default option means * to cancel the login, but there isn't a better way * to guess this. */ translations = new int[] { JOptionPane.CLOSED_OPTION, callback.getDefaultOption() }; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized option type: " + confirmationOptionType); } int confirmationMessageType = callback.getMessageType(); switch (confirmationMessageType) { case ConfirmationCallback.WARNING: messageType = JOptionPane.WARNING_MESSAGE; break; case ConfirmationCallback.ERROR: messageType = JOptionPane.ERROR_MESSAGE; break; case ConfirmationCallback.INFORMATION: messageType = JOptionPane.INFORMATION_MESSAGE; break; default: throw new UnsupportedCallbackException( callback, "Unrecognized message type: " + confirmationMessageType); } }