提问人:griss 提问时间:10/25/2023 最后编辑:queeggriss 更新时间:10/27/2023 访问量:35
为什么它总是显示 JOptionPane 中的代码未定义?
why does it keep showing that a code is undefined in JOptionPane?
问:
我是一个乞丐,我正在尝试运行此代码,但它一直显示问题 这是我的代码:
package detyra:
import javax.swing.JOptionPane;
public class Vendingmachine{
public static void main(String[] args) {
String response;
int dollarbills,stamps,change;
response=JOptionPane.showInputDialog(null, "Enter Dollarbill");
dollarbills=int.parsedouble(response);
stamps=dollarbills/47;
change=dollarbills%47;
JOptionPane.showMessageDialog(null,"Dollar bill:"
+ dollarbills + "\nStamps:" +stamps +"\nChange:" +change);
}
}
这些是问题:
The method showInputDialog(null, String) is undefined for the type JOptionPane JOptionPane.java /detyra/src/javax/swing line 13 Java Problem
Description Resource Path Location Type
The method showInputDialog(null, String) is undefined for the type JOptionPane Vendingmachine.java /detyra/src/detyra line 10 Java Problem
Description Resource Path Location Type
The method showMessageDialog(null, String) is undefined for the type JOptionPane JOptionPane.java /detyra/src/javax/swing line 18 Java Problem
Description Resource Path Location Type
The method showMessageDialog(null, String) is undefined for the type JOptionPane Vendingmachine.java /detyra/src/detyra line 15 Java Problem
答: 暂无答案
上一个:“Main”的多种定义
下一个:如何正确设置 PDO 连接
评论
/detyra/src/javax/swing
听起来绝对不对劲。你自己写了类吗?它应该从 Java 标准库导入,而不是从您自己的项目存储库导入。JOptionPane