class DialogTest
{
public static void main(String[] args)
{
String str = JOptionPane.showDialog("请输入您的姓名:");
System.out.println(str);
System.exit(0);
}
}
以上程序编好后保存为:DialogTest.java编译后有错误
我是按照书上说的编写的。
我是初学者,我觉得问题很简单,望有朋友能帮忙解决!解决后马上给分100!!!

解决方案 »

  1.   

    JOptionPane是什么东西?
    要不要import什么的?错误信息是什么?
      

  2.   

    错误信息:
    DialogTest.java:5:cannot resolve symbol
    symbol : variable JOptionPane
    location: class DialogTest
                    String str = JOptionPane.showDialog("请输入您的姓名:");
                                 ^
    1 error
      

  3.   

    没找到showDialog
    用showInputDialogString str = JOptionPane.showInputDialog("请输入您的姓名:");
    语法:
    showInputDialog
    public static String showInputDialog(Component parentComponent,
                                         Object message,
                                         Object initialSelectionValue)Shows a question-message dialog requesting input from the user and
     parented to parentComponent. The input value will be
     initialized to initialSelectionValue.
     The dialog is displayed on top of the Component's
     frame, and is usually positioned below the Component.Parameters:parentComponent - the parent Component for the
    dialogmessage - the Object to displayinitialSelectionValue - the value used to initialize the input
                     field
      

  4.   

    import javax.swing.JOptionPane;
    class DialogTest
    {
    public static void main(String[] args)
    {
    String str = JOptionPane.showInputDialog("请输入您的姓名:");
    System.out.println(str);
    System.exit(0);
    }
    }
    好了 谢谢 马上100分
      

  5.   

    谢谢,建议多查手册!我本来连JOptionPane是什么都不知道的^_^多谢100分