showInputDialog出错,怎么也找不出错误,汗

时间:2008-06-05 13:55:25   来源:论坛整理  作者:  编辑:chinaitzhe
Java code





Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/



import javax.swing.JOptionPane;

class ShowInput

{

    public static void main(String args[])

    {

        

        String s=(String)JOptionPane.showInputDialog(null, 

                  "Choose one", "Input",

              JOptionPane.INFORMATION_MESSAGE, null,

              "1,2,3", "2");



        int n=Integer.parseInt(s);

        int nn=n*n;

        JOptionPane.showMessageDialog(

            null,

            s "的平方为" nn,

            "标题:平方",

            JOptionPane.PLAIN_MESSAGE);

            System.exit(0);

    }

}




网友回复:
Java code





Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/





import javax.swing.JOptionPane;

class ShowInput

{

    public static void main(String args[])

    {

        

        String s=(String)JOptionPane.showInputDialog(null, 

                  "Choose one", "Input",

              JOptionPane.INFORMATION_MESSAGE, null,

              new Object[] {"1","2","3"}, "2");



        int n=Integer.parseInt(s);

        int nn=n*n;

        JOptionPane.showMessageDialog(

            null,

            s "的平方为" nn,

            "标题:平方",

            JOptionPane.PLAIN_MESSAGE);

            System.exit(0);

    }

}




网友回复:没出错啊!运行正常啊!

lz说的哪不对?
网友回复:搞错~

1楼的正解!!!
网友回复:new Object[] {"1","2","3"}

为什么这里改动了下,就好了呢,不解中....
网友回复:再顶下,2个小时后结贴
网友回复:static Object showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue)
提示用户在可以指定初始选择、可能选择及其他所有选项的模块化的对话框中输入内容。
网友回复:帮顶吧,有错误信息就好了哈
网友回复:showInputDialog方法的参数要求是数组,传一个字符串当然不好用了。
关键字:showInputDialog,出错,错误,

文章评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面