infodialog.java

来自「一个用java写的地震分析软件(无源码)-used to write a sei」· Java 代码 · 共 52 行

JAVA
52
字号
package org.trinet.util.graphics;
import java.awt.*;
import javax.swing.*;
public class InfoDialog {
    public static void informUser(Component component, String msgType, String strMessage) {
        informUser(component, msgType, strMessage, null);
    }

    public static void informUser(Component component, String msgType, String strMessage, JLabel statusLabel) {
	final String plainCommand = "PLAIN";
	final String infoCommand = "INFO";
	final String questionCommand = "QUESTION";
	final String errorCommand = "ERROR";
	final String warningCommand = "WARNING";

	String message = null;
	if (strMessage == null) message = "";
	if (statusLabel != null) statusLabel.setText(strMessage);

	String messageType = msgType.trim().toUpperCase();
        if (messageType.equals(plainCommand)) {
                    JOptionPane.showMessageDialog(component,
                                    strMessage,
                                    "Message",
                                    JOptionPane.PLAIN_MESSAGE);
	} else if (messageType.equals(infoCommand)) {
                    JOptionPane.showMessageDialog(component,
                                    strMessage,
                                    "Information",
                                    JOptionPane.INFORMATION_MESSAGE);
    
	} else if (messageType.equals(questionCommand)) {
                    JOptionPane.showMessageDialog(component,
                                    strMessage,
				    "Question",
                                    JOptionPane.QUESTION_MESSAGE);
	} else if (messageType.equals(errorCommand)) {
                    JOptionPane.showMessageDialog(component,
                                    strMessage,
                                    "Error",
                                    JOptionPane.ERROR_MESSAGE);
	} else if (messageType.equals(warningCommand)) {
                    JOptionPane.showMessageDialog(component,
                                    strMessage,
                                    "Warning",
                                    JOptionPane.WARNING_MESSAGE);
	}
	java.awt.Toolkit.getDefaultToolkit().beep();

    } // end of informUser method
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?