gpt4 book ai didi

java - JOptionPane 信息消息

转载 作者:行者123 更新时间:2023-12-02 02:59:34 24 4
gpt4 key购买 nike

    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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com