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
时会发生这种情况答案 0 :(得分:1)
您正在以错误的方式使用底层构造函数。标题遵循消息而不是消息类型。试试这种方式:
JOptionPane.showMessageDialog(
null,
"message",
"title",
JOptionPane.INFORMATION_MESSAGE,
welcomeIcon);