1

このアプレットは、ブラウザで使用すると正常に動作しますが、アプレット ビューアでは動作しないのはなぜですか?

jGRASP と Eclipse の両方を使用してアプレットを表示しようとしましたが、何をしても次のようになります。

java.lang.NumberFormatException: null on this line of code

int paramCount = Integer.parseInt( getParameter( "count" ) );

なぜこれを行っているのかわかりません。

//file: AppletParameters.java

import javax.swing.JApplet;
import javax.swing.JApplet;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.GridLayout;

public class AppletParameters extends JApplet
{
    private JPanel panel; // panel to display pictures

    public void init( )
    {
        // get the parameter count from the html 'count' parameter
        int paramCount = Integer.parseInt( getParameter( "count" ) );
        // create an array
        ImageIcon [] image = new ImageIcon[paramCount];
        // get each file name from the html 'file' parameter and put into array
        for ( int k=0; k<paramCount; k++ )
            image[k] = new ImageIcon( getImage( getDocumentBase( ), getParameter( "file"+k ) ) );
        // build a new JPanel with GridLayout
        panel = new JPanel( new GridLayout( 2, 5 ) );
        // add images to the panel
        for ( int k=0; k<paramCount; k++ )
            panel.add( new JLabel( image[k] ) );
        // add panel to me (this applet object)
        add( panel );
    }  // end init method
}  // end class
4

1 に答える 1

1

AppletViewer 経由でパラメータをアプレットに渡していますか? 私はあなたが疑わしい。

Eclipse では、[Run] メニューの [Run Configurations...] サブメニュー項目、[Parameters] タブでこれを行います。

ここに画像の説明を入力

于 2012-09-30T03:41:13.040 に答える