Swing 中各种提示框的工具类

来源:互联网 发布:如何重新设置网络账号 编辑:程序博客网 时间:2024/05/17 04:10

由于经常用到这类代码,故贴在这,给自己做个笔记吧

package com.swing.messagebox;    import javax.swing.JOptionPane;    public class GUIUtil23  {      public static final String MESSAGE_WARNING     = " 警告";      public static final String MESSAGE_INFORMATION = " 消息";      public static final String MESSAGE_ERROR = " 错误";        private GUIUtil23()      {          throw new Error("Don't let anyone instantiate this class.");      }            /***      * Warning boxes      *       * @param mesg      */      public static void warningDialog(String mesg)      {          JOptionPane                  .showMessageDialog(                      null,                      "<html><font color=\"yellow\"  style=\"font-weight:bold;" +                      "background-color:#666666\" >"                          + mesg + "</font></html>", MESSAGE_WARNING,                      JOptionPane.WARNING_MESSAGE);      }        /***      * error      *       * @param mesg      */      public static void errorDialog(String mesg)      {          JOptionPane                  .showMessageDialog(                      null,                      "<html><font color=\"red\"  style=\"font-weight:bold;" +                      "background-color:white\" >"                          + mesg + "</font></html>", MESSAGE_ERROR,                      JOptionPane.ERROR_MESSAGE);      }        /***      * information      *       * @param mesg      */      public static void infoDialog(String mesg)      {          JOptionPane.showMessageDialog(null,              "<html><font color=\"green\"  style=\"font-weight:bold;\" >" + mesg                  + "</font></html>", MESSAGE_INFORMATION,              JOptionPane.INFORMATION_MESSAGE);      }  }  


0 0
原创粉丝点击