英文:
Why aren't my JOptionPane messages working?
问题
我在一个if语句中编写了一个消息对话框。当我完成消息的编写后,没有出现错误。但是当我添加错误消息或任何其他消息时,会出现错误,显示"没有合适的方法"和"不适用"。
代码如下:
JOptionPane.showMessageDialog(null, "错误!请重试", JOptionPane.ERROR_MESSAGE);
英文:
I am writing a message dialog within an if statement. When I finish the message there are no errors. When I add an error message or any other message an error says "no suitable method" and "not applicable".
The code looks like this:
OptionPane.showMessageDialog(null, "Wrong! Try again", JOptionPane.ERROR_MESSAGE);
答案1
得分: 0
这是因为没有合适的方法。您需要指定对话框的标题和消息。在这里查看链接。
例如:
JOptionPane.showMessageDialog(null, "错误!请重试", "标题", JOptionPane.ERROR_MESSAGE);
英文:
Thats because there is no suitable method. You need to specify title and message of the dialog. Look here
For example:
JOptionPane.showMessageDialog(null, "Wrong! Try again", "Title", JOptionPane.ERROR_MESSAGE);
专注分享java语言的经验与见解,让所有开发者获益!
评论