Java Code(AppletShapes.java)

import java.applet.*;
import java.awt.*;

public class  AppletShapes extends Applet{
   int x=300,y=100,r=50;
   public void paint(Graphics g){
      g.drawLine(30,300,200,10);
      g.drawOval(x-r,y-r,100,100);
      g.drawRect(400,50,200,100);
      g.fillOval(x-r,y-r,100,100);
      g.fillRect(400,50,200,100);
   }
}

HTML Code(AppletShapes.html)

<html>
     <applet code="AppletShapes.class" height=200 width=320></applet>
</html>

Run this Applet Program in cmd.

1.   Compile Java File:
                    >javac AppletShapes.java
2.   Run Appletviewer
                    >appletviewer AppletShapes.html


0 comments:

Post a Comment

Digital Marketing

Subscribe to RSS Feed Follow me on Twitter!