views:

183

answers:

1
import java.applet.Applet;
import java.awt.Color;
public class sampleapp extends Applet {
    public void init() {
        this.setBackground(Color.BLACK);        
    }
}

I am trying to load the above mentioned applet in mozilla browser.

<applet code="sampleapp.class" width="100" height="100"></applet>

After hosting that web page(index.HTML file where i embed the applet)I have been getting the status information in the web page as "Applet sampleapp started", but i am not getting the applet's content in that hosted web page(in my eg, am not getting the applet's background as black,instead am just getting blank web page) plz help me.

+1  A: 

You'll have to actually draw something by overriding the paint(Graphics g) method. There are some other applet lifecycle methods you may want to override too. Have a look at the Sun tutorial on the Applet lifecycle which includes a working example of a basic applet right near the top.

Asaph