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);
关于java - JOptionPane 信息消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42541693/