-
TestApplet
My applet doesnt run. i get a message saying the applet is not initialised
package applets;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
public class TestApplet extends JApplet {
private boolean isStandalone = false;
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public TestApplet() {
}
public void paint(Graphics g) {
g.drawRect(5, 20, 200, 100);
g.drawRect(10, 20, 100, 150);
g.setColor(Color.red);
g.drawRect(80, 90, 100, 150);
Graphics gTemp = g.create();
gTemp.setColor(Color.green);
gTemp.drawRect(80, 90, 100, 150);
gTemp.dispose();
g.drawRect(40, 10, 250, 120);
}
//Initialize the applet
public void init() {
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
this.setSize(new Dimension(400, 300));
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
//static initializer for setting look & feel
static {
try {
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
}
}
}