gpt4 book ai didi

Java,JOptionPane 无法应用于给定类型

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

当我运行“JOptionPane.showOptionDialog”命令时,出现此错误。我已按照 Oracle 教程页面上的步骤进行操作,但这个步骤就是无法执行。如果需要的话我可以添加我的导入,但是列表很长。

Picture of the error i get

Object[] options = {"Ja", "Nej"}; //the values i want my buttons to have
int test = JOptionPane.showOptionDialog(null, //should make the panel, BlueJ marks showOptionDialog as the problem
spm, //this is a variable i define earlier in the code. Won't be a problem
"TestTwo", //the name of the window
JOptionPane.YES_NO_OPTION, //To be honest, idk what this do
null, //To be honest, idk what this do
options, //implements the values from the top
options[0]); //Don't really know this one either

最佳答案

您缺少参数MessageType

这些是选项 Pane 所需的参数:

JOptionPane.showOptionDialog(parentComponent、消息、标题、optionType、messageType、图标、选项、initialValue)

Object[] options = {"Ja", "Nej"};
int test = JOptionPane.showOptionDialog(null,
spm,
"TestTwo", //the name of the window
JOptionPane.YES_NO_OPTION, //Type of options, those two buttons at bottom of box
JOptionPane.PLAIN_MESSAGE, //The JOptionPane type
null, //Icon to be applied to dialog
options, //implements the values from the top
options[0]); //The default selected component when dialog opens

关于Java,JOptionPane 无法应用于给定类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34032204/

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