2017-03-01 98 views
0
public static String GetName() 
    { 
     String Name; 
     String userName = ""; 
     int GN = 0; 
     if(GN == 0) 
     { 
     userName = 
       JOptionPane.showInputDialog("What is you name?"); 
     GN = 1; 
     } 
     Name = userName; 
     return Name; 
    } 
     public static void Welcome_P() 
     { 
      JDialog.setDefaultLookAndFeelDecorated(true); 
      Icon welcomeIcon = new ImageIcon("Welcome.gif"); 

       JOptionPane.showMessageDialog(null, "\t \t▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n" 
       + "\t \t▇▇Welcome " + GetName() + " to " + GetAuthorsName() + " Quirky Program▇▇\n" 
       + "\t \t▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n", JOptionPane.INFORMATION_MESSAGE, "Welcome", welcomeIcon); 
     } 

我不斷收到這條消息,我是新來編程我不明白我需要做什麼來解決這個問題。不兼容的類型:int不能轉換爲String。發生這種情況時,我把JOptionPane.Information_MessageJOptionPane信息消息

+0

你的問題是? – gattsbr

回答

1

您正在使用的底層構造函數的方式是錯誤的。標題跟隨消息而不是消息類型。試試這個方法:

JOptionPane.showMessageDialog(
    null, 
    "message", 
    "title", 
    JOptionPane.INFORMATION_MESSAGE, 
    welcomeIcon);