2013-10-26 139 views
-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); 

正在此錯誤沒有合適的方法發現showMessageDialog

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) 
+3

你認爲錯誤的含義是什麼?看看你的方法調用,特別是衆多的','。 –

回答

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

+0

這仍然不是解決方案,因爲第一個參數代表'parentComponent'。 –

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) 

我猜「有」,而不是「+」有問題。

0

您在輸出語句之前忘了null,如在JOptionPane.showMessageDialog(null,「....」); ,你不能使用「」唯一‘+’

0
JOptionPane.showMessageDialog(null,"Your text "+anyVariable+"any more text", 
    "The BoxHeader title", JOptionPane.PLAIN_MESSAGE); 

你必須把null第一,那麼不要忘記‘框標題標題’後跟一個逗號(,)和JOptionPane.PLAIN_MESSAGE

相關問題