
Java Testing Section
Above was a simple Java applet that I wrote to do one
thing: display an image. Unfortunately, it is not working.
It's behavior terminates operation of Internet Explore v6.0 after a few seconds,
I don't know what it does with other browsers, since I don't use them. The
applet has been removed for the time being while I determine why it is
misbehaving in this manner. Below is the source code for the applet (I am currently using JBuilder 2,
Standard Edition). If any of you that visit my site have any ideas, I will gladly
entertain them.
import java.applet.*;
import java.awt.*;
import java.awt.Graphics;
import java.awt.Image;
import java.net.*;
public class ImageView extends Applet
{
private String m_imageURL = "";
private URL m_URL = null;
private String error = null;
private Image m_image = null;
private boolean m_AutoSize = false;
private Boolean StringToBool;
private final String PARAM_ImageURL = "ImageURL";
private final String PARAM_ImageAutoSize = "ImageAutoSize";
public ImageView()
{
}
public String getAppletInfo()
{
return "Name: ImageView\r\n" +
"Author: Geoff A. Stanford\r\n" +
"Created with Borland JBuilder 2 Standard";
}
public String[][] getParameterInfo()
{
if(param != null)
{
StringToBool = new Boolean(param);
m_AutoSize = StringToBool.booleanValue();
}
try
{
m_URL = new URL(m_imageURL);
m_image = getImage(m_URL);
}
catch(MalformedURLException e)
{
error = new String("Image is unavailable: " + e.getMessage());
}
catch(SecurityException e)
{
error = new String("Security exception raised: " + e.getMessage());
}
catch(NullPointerException e)
{
error = new String("Null Pointer Exception: " +
e.getMessage());
}
if(m_AutoSize)
resize(m_image.getWidth(this),
m_image.getHeight(this));
}
public void destroy()
{
}
public void paint(Graphics g)
{
if(error == null)
{
g.drawImage(m_image, 0, 0, null);
update(g);
}
else
{
g.setColor(new Color(0,0,0));
g.drawString(error, 20, 30);
update(g);
}
}
}