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