📄 i18noptionpane.java
字号:
/*
* Created on 15/05/2004
*
*/
package it.businesslogic.ireport.util;
import java.awt.Component;
import javax.swing.Icon;
import javax.swing.JOptionPane;
/**
* A internacionalization support for all static methods of JOptionPane.
*
* @author Egon
*
*/
public class I18nOptionPane {
/**
* Couldn't be instancied.
*/
private I18nOptionPane() {
super();
}
/**
* Brings up an internal confirmation dialog panel. The dialog is a information-message dialog titled "Message".
*
* @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
* @param messageCID message country identification for a message to be displayed.
*/
public static void showInternalMessageDialog(Component parentComponent, String messageCID){
String message = messageCID;
if(messageCID != null){
message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
}
JOptionPane.showInternalMessageDialog(parentComponent, message);
}
/**
* Brings up an internal dialog panel that displays a message using a default icon determined by the messageType parameter.
* @param parentComponent the parent Component for the dialog
* @param messageCID message country identification for a message to be displayed.
* @param titleCID message country identification for the String to display in the dialog title bar
* @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
*/
public static void showInternalMessageDialog(Component parentComponent, String messageCID, String titleCID, int messageType){
String message = messageCID;
if(messageCID != null){
message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
}
String title = titleCID;
if(titleCID != null){
title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
}
JOptionPane.showInternalMessageDialog(parentComponent, message, title, messageType);
}
/**
* Brings up a dialog displaying a message, specifying all parameters.
* @param parentComponent the parent Component for the dialog
* @param messageCID message country identification for a message to be displayed.
* @param titleCID message country identification for the String to display in the dialog title bar
* @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
* @param icon the icon to display in the dialog
*/
public static void showInternalMessageDialog(Component parentComponent, String messageCID, String titleCID, int messageType, Icon icon){
String message = messageCID;
if(messageCID != null){
message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
}
String title = titleCID;
if(titleCID != null){
title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
}
JOptionPane.showInternalMessageDialog(parentComponent, message, title, messageType, icon);
}
/**
* Brings up an internal dialog panel with the options Yes, No and Cancel; with the title, Select an Option.
* @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
* @param messageCID message country identification for a message to be displayed.
*/
public static int showInternalConfirmDialog(Component parentComponent,
String messageCID)
{
String message = messageCID;
if(messageCID != null){
message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
}
return JOptionPane.showInternalConfirmDialog(parentComponent, message);
}
/**
* Brings up a internal dialog panel where the number of choices is determined by the optionType parameter.
* @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
* @param messageCID message country identification for a message to be displayed.
* @param titleCID message country identification for the String to display in the dialog title bar
* @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
*/
public static int showInternalConfirmDialog(Component parentComponent,
String messageCID, String titleCID,
int optionType)
{
String message = messageCID;
if(messageCID != null){
message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
}
String title = titleCID;
if(titleCID != null){
title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
}
return JOptionPane.showInternalConfirmDialog(parentComponent, message, title, optionType);
}
/**
* Brings up an internal dialog panel where the number of choices is determined by the optionType parameter, where the messageType parameter determines the icon to display. The messageType parameter is primarily used to supply a default icon from the Look and Feel.
* @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
* @param messageCID message country identification for a message to be displayed.
* @param titleCID message country identification for the String to display in the dialog title bar
* @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
* @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
*/
public static int showInternalConfirmDialog(Component parentComponent,
String messageCID, String titleCID,
int optionType, int messageType)
{
String message = messageCID;
if(messageCID != null){
message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
}
String title = titleCID;
if(titleCID != null){
title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
}
return JOptionPane.showInternalConfirmDialog(parentComponent, message, title, optionType, messageType);
}
/**
* Brings up an internal dialog panel with a specified icon, where the number of choices is determined by the optionType parameter. The messageType parameter is primarily used to supply a default icon from the look and feel.
* @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
* @param messageCID message country identification for a message to be displayed.
* @param titleCID message country identification for the String to display in the dialog title bar
* @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
* @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
* @param icon the icon to display in the dialog
*/
public static int showInternalConfirmDialog(Component parentComponent,
String messageCID, String titleCID,
int optionType, int messageType, Icon icon)
{
String message = messageCID;
if(messageCID != null){
message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
}
String title = titleCID;
if(titleCID != null){
title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
}
return JOptionPane.showInternalConfirmDialog(parentComponent, message, title, optionType, messageType, icon);
}
/**
* Brings up an internal dialog panel with a specified icon, where the initial choice is determined by the initialValue parameter and the number of choices is determined by the optionType parameter.
* If optionType is YES_NO_OPTION, or YES_NO_CANCEL_OPTION and the options parameter is null, then the options are supplied by the Look and Feel.
*
* The messageType parameter is primarily used to supply a default icon from the look and feel.
* @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
* @param messageCID message country identification for a message to be displayed.
* @param titleCID message country identification for a title to be displayed.
* @param optionType an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
* @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
* @param icon the icon to display in the dialog
* @param optionsCID an array of message CIDs indicating the possible choices the user can make
* @param initialCIDValue the message CID that represents the default selection for the dialog; only meaningful if options is used; can be null
* @return an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the dialog
*/
public static int showInternalOptionDialog(Component parentComponent,
String messageCID,
String titleCID,
int optionType,
int messageType,
Icon icon,
String[] optionsCID,
String initialCIDValue)
{
String message = messageCID;
if(messageCID != null){
message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
}
String title = titleCID;
if(titleCID != null){
title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
}
String initialValue = initialCIDValue;
if(initialCIDValue != null){
initialValue = it.businesslogic.ireport.util.I18n.getString(initialCIDValue, initialCIDValue);
}
String[] options = optionsCID;
if(optionsCID != null){
for(int i = 0; i < optionsCID.length; i++){
if (optionsCID[i] != null){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -