JOptionPane.showMessageDialog("Employee Id Is "+
empid , "\nEmploye Name is " + employeename ,
"\nFather Name is " + fathername ,
"\nJob Catagory is " + jobcatagory,
"\nAge is " + age,
"\nEducation is " + education,
"\nPay Scale is " + payscal,
"\nNIC is " + NIC );
我收到此错误
no suitable method found for showMessageDialog(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
method javax.swing.JOptionPane.showMessageDialog(java.awt.Component,java.lang.Object,java.lang.String,int,javax.swing.Icon) is not applicable
(actual and formal argument lists differ in length)
method javax.swing.JOptionPane.showMessageDialog(java.awt.Component,java.lang.Object,java.lang.String,int) is not applicable
(actual and formal argument lists differ in length)
method javax.swing.JOptionPane.showMessageDialog(java.awt.Component,java.lang.Object) is not applicable
(actual and formal argument lists differ in length)
答案 0 :(得分:2)
您使用,
代替+进行字符串连接
JOptionPane.showMessageDialog("Employee Id Is "+
empid , "\nEmploye Name is " + employeename +
"\nFather Name is " + fathername +
"\nJob Catagory is " + jobcatagory +
"\nAge is " + age +
"\nEducation is " + education +
"\nPay Scale is " + payscal+
"\nNIC is " + NIC );
您将错误的参数传递给showMessageDialog()方法。
请参阅JOptionPane及其方法签名here
答案 1 :(得分:0)
javax.swing.JOptionPane提供了三种重写方法:
javax.swing.JOptionPane.showMessageDialog(java.awt.Component,java.lang.Object,java.lang.String,int,javax.swing.Icon)
javax.swing.JOptionPane.showMessageDialog(java.awt.Component,java.lang.Object,java.lang.String,int)
javax.swing.JOptionPane.showMessageDialog(java.awt.Component,java.lang.Object)
你正在调用一个未在该类中定义的方法:
showMessageDialog(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
我想“,”而不是“+”有问题。
答案 2 :(得分:0)
你在输出语句之前忘记了null,如在JOptionPane.showMessageDialog中那样(null," ...."); 你不能使用","只有" +"
答案 3 :(得分:0)
//C[E/F]
你必须先放JOptionPane.showMessageDialog(null,"Your text "+anyVariable+"any more text",
"The BoxHeader title", JOptionPane.PLAIN_MESSAGE);
,然后不要忘记" Box标题"后跟逗号(,)和null