Java Code Examples for javax.swing.JOptionPane#WARNING_MESSAGE

The following examples show how to use javax.swing.JOptionPane#WARNING_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: TestViewer.java    From sis with Apache License 2.0 7 votes vote down vote up
/**
 * Saves the image of the currently selected frame.
 */
private void savePNG() {
    final RenderedImage image = getSelectedImage();
    if (image != null) {
        final File file = new File(System.getProperty("user.home"), "ImageTest.png");
        final String title, message;
        final int type;
        if (file.exists()) {
            type    = JOptionPane.WARNING_MESSAGE;
            title   = "Confirm overwrite";
            message = "File " + file + " exists. Overwrite?";
        } else {
            type    = JOptionPane.QUESTION_MESSAGE;
            title   = "Confirm write";
            message = "Save in " + file + '?';
        }
        if (JOptionPane.showInternalConfirmDialog(desktop, message, title,
                JOptionPane.YES_NO_OPTION, type) == JOptionPane.OK_OPTION)
        {
            try {
                ImageTestCase.savePNG(image, file);
            } catch (IOException e) {
                JOptionPane.showInternalMessageDialog(desktop, e.toString(),
                        "Error", JOptionPane.WARNING_MESSAGE);
            }
        }
    }
}
 
Example 2
Source File: MessageDialogs.java    From FancyBing with GNU General Public License v3.0 6 votes vote down vote up
public void showWarning(String disableKey, Component parent,
                        String mainMessage, String optionalMessage,
                        boolean isCritical)
{
    if (checkDisabled(disableKey))
        return;
    int type;
    if (isCritical)
        type = JOptionPane.WARNING_MESSAGE;
    else
        type = JOptionPane.PLAIN_MESSAGE;
    Object[] options = { i18n("LB_CLOSE") };
    Object defaultOption = options[0];
    show(disableKey, parent, "", mainMessage, optionalMessage, type,
         JOptionPane.DEFAULT_OPTION, options, defaultOption, -1);
}
 
Example 3
Source File: SourceFoldersPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void showInvalidRootsWarning (Set<File> invalidRoots) {
    JButton closeOption = new JButton (NbBundle.getMessage(SourceFoldersPanel.class,"CTL_SourceFolderPanel_Close"));
    closeOption.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(SourceFoldersPanel.class,"AD_SourceFolderPanel_Close"));        
    JPanel warning = new WarningDlg (invalidRoots);                
    String message = NbBundle.getMessage(SourceFoldersPanel.class,"MSG_InvalidRoot");
    JOptionPane optionPane = new JOptionPane (new Object[] {message, warning},
        JOptionPane.WARNING_MESSAGE,
        0, 
        null, 
        new Object[0], 
        null);
    optionPane.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage(SourceFoldersPanel.class,"AD_InvalidRootDlg"));
    DialogDescriptor dd = new DialogDescriptor (optionPane,
        NbBundle.getMessage(SourceFoldersPanel.class,"TITLE_InvalidRoot"),
        true,
        new Object[] {
            closeOption,
        },
        closeOption,
        DialogDescriptor.DEFAULT_ALIGN,
        null,
        null);                
    DialogDisplayer.getDefault().notify(dd);
}
 
Example 4
Source File: StartupDialog.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static int styleFromMessageType(int messageType) {
    switch (messageType) {
    case JOptionPane.ERROR_MESSAGE:
        return JRootPane.ERROR_DIALOG;
    case JOptionPane.QUESTION_MESSAGE:
        return JRootPane.QUESTION_DIALOG;
    case JOptionPane.WARNING_MESSAGE:
        return JRootPane.WARNING_DIALOG;
    case JOptionPane.INFORMATION_MESSAGE:
        return JRootPane.INFORMATION_DIALOG;
    case JOptionPane.PLAIN_MESSAGE:
    default:
        return JRootPane.PLAIN_DIALOG;
    }
}
 
Example 5
Source File: UiUtils.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
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 6
Source File: MessageDialogs.java    From FancyBing with GNU General Public License v3.0 5 votes vote down vote up
/** Show warning message to confirm destructive actions.
    @return true, if destructive was chosen; false if cancel was chosen. */
public boolean showWarningQuestion(String disableKey, Component parent,
                                   String mainMessage,
                                   String optionalMessage,
                                   String destructiveOption,
                                   String nonDestructiveOption,
                                   boolean isCritical)
{
    if (checkDisabled(disableKey))
        return true;
    Object[] options = new Object[2];
    if (Platform.isMac())
    {
        options[0] = nonDestructiveOption;
        options[1] = destructiveOption;
    }
    else
    {
        options[0] = destructiveOption;
        options[1] = nonDestructiveOption;
    }
    Object defaultOption = nonDestructiveOption;
    int type;
    if (isCritical)
        type = JOptionPane.WARNING_MESSAGE;
    else
        type = JOptionPane.PLAIN_MESSAGE;
    Object result = show(disableKey, parent, "", mainMessage,
                         optionalMessage, type, JOptionPane.YES_NO_OPTION,
                         options, defaultOption, -1);
    return (result == destructiveOption);
}
 
Example 7
Source File: EncryptBackMultiplePm.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
	BatchEncryptionResult ret = null;
	try {
		ret = encryptFiles();
	} catch (Throwable t) {
		log.error("Encrypt all failed", t);
		if (ret == null) {
			ret = new BatchEncryptionResult();
		}
		ret.errors.put("OPERATION", t);
	} finally {
		isDisableControls.setValueByOwner(false);
		if (ret == null) {
			ret = new BatchEncryptionResult();
		}

		// summary
		String msg = buildSummaryMessage(ret);
		int severity = ret.errors.size() + ret.warnings.size() == 0 ? JOptionPane.INFORMATION_MESSAGE
				: JOptionPane.WARNING_MESSAGE;
		UiUtils.messageBox(UiUtils.actionEvent(findRegisteredWindowIfAny(), "BkgOpEncryptBackAll"), msg,
				Messages.get("encrypBackMany.action"), severity);

		// close window
		host.handleClose();
	}
}
 
Example 8
Source File: SwingNotifier.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
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 9
Source File: DialogCallbackHandler.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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: DialogCallbackHandler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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 11
Source File: DialogCallbackHandler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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 vote down vote up
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: UiUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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 14
Source File: DialogCallbackHandler.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
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 jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
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 jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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 JDKSourceCode1.8 with MIT License 4 votes vote down vote up
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: BEInternalFrameTitlePane.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
 * Updates any state dependant upon the JInternalFrame being shown in
 * a <code>JOptionPane</code>.
 */
private void updateOptionPaneState()
{
	int type = -2;
	boolean closable = wasClosable;
	Object obj = frame.getClientProperty("JInternalFrame.messageType");

	if (obj == null)
	{
		// Don't change the closable state unless in an JOptionPane.
		return;
	}
	if (obj instanceof Integer)
	{
		type = ((Integer) obj).intValue();
	}
	switch (type)
	{
		case JOptionPane.ERROR_MESSAGE:
			selectedBackgroundKey = "OptionPane.errorDialog.titlePane.background";
			selectedForegroundKey = "OptionPane.errorDialog.titlePane.foreground";
			selectedShadowKey = "OptionPane.errorDialog.titlePane.shadow";
			closable = false;
			break;
		case JOptionPane.QUESTION_MESSAGE:
			selectedBackgroundKey = "OptionPane.questionDialog.titlePane.background";
			selectedForegroundKey = "OptionPane.questionDialog.titlePane.foreground";
			selectedShadowKey = "OptionPane.questionDialog.titlePane.shadow";
			closable = false;
			break;
		case JOptionPane.WARNING_MESSAGE:
			selectedBackgroundKey = "OptionPane.warningDialog.titlePane.background";
			selectedForegroundKey = "OptionPane.warningDialog.titlePane.foreground";
			selectedShadowKey = "OptionPane.warningDialog.titlePane.shadow";
			closable = false;
			break;
		case JOptionPane.INFORMATION_MESSAGE:
		case JOptionPane.PLAIN_MESSAGE:
			selectedBackgroundKey = selectedForegroundKey = selectedShadowKey = null;
			closable = false;
			break;
		default:
			selectedBackgroundKey = selectedForegroundKey = selectedShadowKey = null;
			break;
	}
	if (closable != frame.isClosable())
	{
		frame.setClosable(closable);
	}
}
 
Example 19
Source File: DialogCallbackHandler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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 dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
}