本文整理汇总了Java中javax.swing.JOptionPane.WARNING_MESSAGE属性的典型用法代码示例。如果您正苦于以下问题:Java JOptionPane.WARNING_MESSAGE属性的具体用法?Java JOptionPane.WARNING_MESSAGE怎么用?Java JOptionPane.WARNING_MESSAGE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.JOptionPane
的用法示例。
在下文中一共展示了JOptionPane.WARNING_MESSAGE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showInvalidRootsWarning
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);
}
示例2: showIllegalRootsDialog
/**
* Opens the standard dialog for warning an user about illegal source roots.
* @param roots the set of illegal source/test roots
*/
public static void showIllegalRootsDialog (Set/*<File>*/ roots) {
JButton closeOption = new JButton (NbBundle.getMessage(SourceRootsUi.class,"CTL_SourceRootsUi_Close"));
closeOption.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(SourceRootsUi.class,"AD_SourceRootsUi_Close"));
JPanel warning = new WarningDlg (roots);
String message = NbBundle.getMessage(SourceRootsUi.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(SourceRootsUi.class,"AD_InvalidRootDlg"));
DialogDescriptor dd = new DialogDescriptor (optionPane,
NbBundle.getMessage(SourceRootsUi.class,"TITLE_InvalidRoot"),
true,
new Object[] {
closeOption,
},
closeOption,
DialogDescriptor.DEFAULT_ALIGN,
null,
null);
DialogDisplayer.getDefault().notify(dd);
}
示例3: getJOptionType
/**
* Returns the JOptionPane Type depending on the Error-Level
*
* @return - JOptionPane Type
*/
protected int getJOptionType() {
switch(this.errorLevel) {
case ERROR_LEVEL_NOTICE:
return JOptionPane.INFORMATION_MESSAGE;
case ERROR_LEVEL_WARNING:
return JOptionPane.WARNING_MESSAGE;
case ERROR_LEVEL_ERROR:
return JOptionPane.ERROR_MESSAGE;
case ERROR_LEVEL_FATAL:
return JOptionPane.ERROR_MESSAGE;
case ERROR_LEVEL_INFO:
default:
return JOptionPane.INFORMATION_MESSAGE;
}
}
示例4: publish
public void publish(LogRecord logRecord)
{
if (isLoggable(logRecord))
{
int type;
String title;
if (logRecord.getMessage().charAt(0) != '\b') {
return;
}
int val = logRecord.getLevel().intValue();
if (val >= Level.SEVERE.intValue())
{
title = "Error";
type = JOptionPane.ERROR_MESSAGE;
}
else if (val >= Level.WARNING.intValue())
{
title = "Warning";
type = JOptionPane.WARNING_MESSAGE;
}
else
{
title = "Note";
type = JOptionPane.INFORMATION_MESSAGE;
}
String record = getFormatter().formatMessage(logRecord).replaceAll("[\b]","");
if (record.contains("\n"))
record = "<HTML>" + record.replace("\n", "<br>") + "</HTML>";
// stay off FX or other problem threads
final String msg = record;
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
JOptionPane.showMessageDialog(FocusManager.getCurrentManager().getActiveWindow(), msg, title, type);
}
});
}
}
示例5: showMessageDialog
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;
}
示例6: setCallback
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);
}
}