import java.awt.*;
import java.applet.*;
public class sample extends Applet
{
String chr;
public void init()
{
setBackground(Color.black);
setForeground(Color.white);
chr="Inside init() ---->";
}
public void start()
{
chr+="Inside start() ---->";
}
public void paint(Graphics g)
{
chr+="Inside paint() ---->";
g.drawString(chr,10,0);
}
}
** This is my first applet, and as i ran this on complier..it showed an error..."main method not found...declare it as..." I dont understand the problem as i had read that applets do not require main(). **
Try this.
public static void main(String[] args){
sample x = new sample();
x.init();
}
Also the application would also run by just doing this
sample x = new sample();
It is only showing a blank applet. is that what you are trying to do?
I tried running this in eclipse.
A simple googling shows this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.