为什么我的JOptionPane消息没有起作用?

huangapple 未分类评论51阅读模式
英文:

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);

huangapple
  • 本文由 发表于 2020年4月8日 02:26:26
  • 转载请务必保留本文链接:https://java.coder-hub.com/61086864.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定