Showing posts with label overiding the Paint Method of Applet Class. Show all posts
Showing posts with label overiding the Paint Method of Applet Class. Show all posts

Friday, 19 August 2011

Applet Class

//applet  wil run in web pages


import java.awt.*;
import java.applet.Applet;
public class MyApplet extends Applet{

public void init(){
Button b=new Button("OK");
this.add(b);


}

public void paint(Graphics g){
  g.drawRect(150,150,200,200);  
  g.setColor(Color.RED);
  g.fillRect(150,150,200,200); 
}

public static void main(String n[]){

MyApplet ma=new MyApplet();

ma.init();
ma.paint();
ma.stop();

}//end of main


}//end of class




//its html file would be
<HTML>
<APPLET CODE="MyApplet.class"  height=400 width=400> </applet>
</HTML>