1

好的,这是我的第一个小程序,我多次尝试绕过这个异常。任何形式的帮助将不胜感激!谢谢!

这是我的代码:

package Application;

import java.applet.*;
import java.awt.*;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JPanel;

public class FirstApplet extends JApplet
{
    private JPanel jpnlMain = new JPanel(new BorderLayout());
    private JPanel jpnlBoutton = new JPanel(new GridLayout(5,5));
    private JPanel jpnlLogo = new JSplash(this);
    private GenericRoundedButton[] jbtnAllo = new GenericRoundedButton[10];

    public void init(){
        super.init();
        this.add(jpnlMain);
        for(int i =0;i<jbtnAllo.length;i++){
            jbtnAllo[i] = new GenericRoundedButton();
            jpnlBoutton.add(jbtnAllo[i]);
        }       
        jpnlMain.add(jpnlBoutton,"North");
        jpnlMain.add(jpnlLogo,"Center");
    }
}

这是我的 HTML 代码:

<html>
    <title>The ImageDemo applet</title>
    <hr>
        <applet code="Application.FirstApplet.class" width="400" height="400">
    </applet>
    <hr>
</html>
4

1 回答 1

1

此代码(与您的代码非常接近的 SSCCE)加载时不会显示任何异常。我可以由此得出结论,问题在于您选择不包含的代码部分。

// <applet code=FirstApplet width=400 height=400></applet>
import java.awt.*;
import javax.swing.*;

public class FirstApplet extends JApplet
{
    private JPanel jpnlMain = new JPanel(new BorderLayout());
    private JPanel jpnlBoutton = new JPanel(new GridLayout(5,5));
    private JPanel jpnlLogo = new JPanel();
    private JButton[] jbtnAllo = new JButton[10];

    public void init(){
        super.init();
        this.add(jpnlMain);
        for(int i =0;i<jbtnAllo.length;i++){
            jbtnAllo[i] = new JButton();
            jpnlBoutton.add(jbtnAllo[i]);
        }
        jpnlMain.add(jpnlBoutton,"North");
        jpnlMain.add(jpnlLogo,"Center");
    }
}
于 2012-05-15T21:42:09.993 回答