gpt4 book ai didi

java - 似乎无法让 JOptionPane 下拉菜单正常工作

转载 作者:行者123 更新时间:2023-12-01 22:28:03 26 4
gpt4 key购买 nike

我很确定应该没问题,但我不断收到此警告!

String[] trollDo= {"Try and sneak the horses away.",
"Go back and tell the others.",
"Kill the trolls."};
String trollChoice =(String) JOptionPane.showInputDialog(null,
"What will "+playerName+" do?",null,JOptionPane.QUESTION_MESSAGE,
trollDo,trollDo[0]);

最佳答案

您应该会收到编译错误,例如...

error: no suitable method found for showInputDialog(<null>,String,<null>,int,String[],String)
String trollChoice = (String) JOptionPane.showInputDialog(
^
method JOptionPane.showInputDialog(Object) is not applicable
(actual and formal argument lists differ in length)
method JOptionPane.showInputDialog(Object,Object) is not applicable
(actual and formal argument lists differ in length)
method JOptionPane.showInputDialog(Component,Object) is not applicable
(actual and formal argument lists differ in length)
method JOptionPane.showInputDialog(Component,Object,Object) is not applicable
(actual and formal argument lists differ in length)
method JOptionPane.showInputDialog(Component,Object,String,int) is not applicable
(actual and formal argument lists differ in length)
method JOptionPane.showInputDialog(Component,Object,String,int,Icon,Object[],Object) is not applicable
(actual and formal argument lists differ in length)
1 error

这意味着您缺少icon参数...

String trollChoice = (String) JOptionPane.showInputDialog(
null,
"What will " + playerName + " do?",
null,
JOptionPane.QUESTION_MESSAGE,
null, // This one here
trollDo,
trollDo[0]);

确保您正在咨询 JavaDocs并使用您的 IDE 选择和填充方法参数

关于java - 似乎无法让 JOptionPane 下拉菜单正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28357936/

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