Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JOptionPane信息消息_Java_Joptionpane - Fatal编程技术网

Java JOptionPane信息消息

Java JOptionPane信息消息,java,joptionpane,Java,Joptionpane,我一直收到这个信息,我是编程新手,我不知道我需要做什么来解决这个问题。不兼容的类型:无法将int转换为字符串。当我放置JOptionPane.Information\u消息时,会发生这种情况。您使用的底层构造函数的方式错误。标题在消息后面,而不是消息类型。试着这样做: public static String GetName() { String Name; String userName = ""; int GN = 0;

我一直收到这个信息,我是编程新手,我不知道我需要做什么来解决这个问题。不兼容的类型:无法将int转换为字符串。当我放置JOptionPane.Information\u消息时,会发生这种情况。您使用的底层构造函数的方式错误。标题在消息后面,而不是消息类型。试着这样做:

    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);
    }

您正在以错误的方式使用基础构造函数。标题在消息后面,而不是消息类型。试着这样做:

    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);
    }

你的问题是什么?你的问题是什么?