当我在浏览器中使用这个小程序时,它可以正常工作,但为什么它不能与小程序查看器一起工作?
我曾尝试同时使用 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