-1
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)
4

4 回答 4

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 及其方法签名

于 2013-10-26T16:16:22.277 回答
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)

我想“,”而不是“+”有问题。

于 2013-10-26T16:25:44.740 回答
0

您忘记了输出语句之前的空值,如 JOptionPane.showMessageDialog(null, "...."); 而且你不能使用“,”,只能使用“+”

于 2014-10-14T19:52:24.460 回答
0
JOptionPane.showMessageDialog(null,"Your text "+anyVariable+"any more text",
    "The BoxHeader title", JOptionPane.PLAIN_MESSAGE);

您必须先放null,然后不要忘记“Box header title”,后跟逗号(,)和JOptionPane.PLAIN_MESSAGE

于 2015-10-15T00:24:33.820 回答