少了括号
f.getContentPane().add(new initarray("Hello Java!"));

解决方案 »

  1.   

    哈哈,我也认为你这个问题,用appletviewer看看!效果不错哦!
      

  2.   

    public initarray(String message)
       {
           theMessage = message;
           theButton = new JButton("按钮");
           getContentPane().setLayout (new FlowLayout());
           getContentPane().add(theButton);
           theButton.addActionListener(this);
           addMouseMotionListener(this);
       }f.getContentPane().add(new initarray("Hello Java!"));
    俺没看到什么高级的效果哦,好菜~~~~~~~~~~~
      

  3.   

    除了上面的说的错误以外,initarray()中在运行时会出异常。
    我用的是j2sdk1.4.1_01。
    修改如下:public initarray(String message)
       {
           theMessage = message;
           theButton = new JButton("按钮");
           getContentPane().setLayout (new FlowLayout());
           getContentPane().add(theButton);
           theButton.addActionListener(this);
           addMouseMotionListener(this);
       }
      

  4.   

    我用的也是j2sdk1.4.1_01
    我怎么不行啊。
    载入:无法实例化 initarray.class。
    java.lang.InstantiationException: initarray
            at java.lang.Class.newInstance0(Class.java:281)
            at java.lang.Class.newInstance(Class.java:249)
            at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)
            at sun.applet.AppletPanel.runLoader(AppletPanel.java:477)
            at sun.applet.AppletPanel.run(AppletPanel.java:290)
            at java.lang.Thread.run(Thread.java:536)