
In order for an applet to be shared successfully under JAMM, the following guidelines must be followed.
If the applet needs these widgets, use pure Java alternatives, like Netscape's IFC widgets.
When using an offscreen image (e.g., for animation double buffering), test that the Graphics object for that image is not null.
// ...
Image offImage = null;
Graphics offGraphics = null;
// ..
// Incorrect:
public void paint(Graphics g) {
if (offImage == null) {
offImage = createImage(size().width, size().height);
offGraphics = offImage.getGraphics();
}
}
// Correct
public void paint(Graphics g) {
if (offGraphics == null) {
offImage = createImage(size().width, size().height);
offGraphics = offImage.getGraphics();
}
}
// also Correct
public void paint(Graphics g) {
if (offImage == null) {
offImage = createImage(size().width, size().height);
}
if (offGraphics == null) {
offGraphics = offImage.getGraphics();
}
}
// Incorrect
Frame parentFrame = null;
// ...
if (parentFrame == null) {
Component comp = this;
while !(comp instanceof Frame)
comp = comp.getParent();
parentFrame = (Frame)comp;
}
Dialog dialog = new Dialog(floor, parentFrame);
// Correct
Component comp = this;
while !(comp instanceof Frame)
comp = comp.getParent();
Dialog dialog = new Dialog(floor, (Frame)comp);
Return to JAMM Main Page
James "Bo" Begole January 21, 1997