java - error: no suitable method found for showInputDialog(,String,int,,String[],String)
问题描述
I'm trying to create a fraction calculator in java, I'm using the drop box int Joptionpane to display the arithmetic operations, but I keep getting an error whenever I compile the code.
String [] sChoice = {"+","-","*","/"};
JComboBox<String> jcb = new
JComboBox<>(sChoice);
String input = (String)JOptionPane.showInputDialog(null,"Choise your opperator",
JOptionPane.INFORMATION_MESSAGE,null,sChoice,sChoice[0]);
Heres the full error I'm getting.
.java:47: error: no suitable method found for showInputDialog(,String,int,,String[],String) String input = (String)JOptionPane.showInputDialog(null,"Choise your opperator", ^ 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)
解决方案
Could you please add the formatted stack trace.
Number of arguments might be the issue.
Try changling like this, for example
JOptionPane.showInputDialog(null, " " , "txt");
推荐阅读
- angular - 注入到组件的服务在构造函数之外未定义
- agens-graph - 如何在 AgnsGraph 上的第一个 CYPHER 语句中使用 with 子句?
- c# - 为什么它给我一个 NullReferenceException 但没有错误
- javascript - Google Maps JavaScript API 错误 您要授权的站点 URL:
- google-app-engine - 通过 Cloud Scheduler 使用管理 API 方法
- python - 如何从 Python 中的 CSV 文件中删除空双引号?
- php - 从 MySQL 数据库中删除,表单不会在 PHP 中显示
- terraform - 如何更改 Compute Engine 虚拟机中的 StackDriver 日志记录代理配置?
- mongo-cxx-driver - bsoncxx:to_json 导致双值截断
- ajax - 如何在ajax中刷新和显示当前输出请求?