JOptionPane 信息消息

JOptionPane Information Message

    public static String GetName()
    {
        String Name;
        String userName = "";
        int GN = 0;
        if(GN == 0)
        {
        userName =
                JOptionPane.showInputDialog("What is you name?");
        GN = 1;
        }
        Name = userName;
        return Name;
    }
    public static void Welcome_P()
    {
        JDialog.setDefaultLookAndFeelDecorated(true);
        Icon welcomeIcon = new ImageIcon("Welcome.gif");

        JOptionPane.showMessageDialog(null, "\t \t▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"
                + "\t \t▇▇Welcome " + GetName() + " to " + GetAuthorsName() + " Quirky Program▇▇\n"
                + "\t \t▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n", JOptionPane.INFORMATION_MESSAGE, "Welcome", welcomeIcon);
    }

我不断收到此消息,我是编程新手,我不明白我需要做什么来解决这个问题。不兼容的类型:int 无法转换为 String。当我把 JOptionPane.Information_Message

您以错误的方式使用了底层构造函数。标题跟在消息之后,而不是消息类型。试试这样:

JOptionPane.showMessageDialog(
    null, 
    "message", 
    "title",
    JOptionPane.INFORMATION_MESSAGE, 
    welcomeIcon);