How to Draw Shapes in an Applet in Core Java

In this tutorial how to draw shapes in an Applet in Core Java is shown.

Code:

GraphicsDemo.java

/* <applet code=”GraphicsDemo.class” width=”500″ height=”500″> </applet>*/

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

public class GraphicsDemo extends Applet
{
public void paint(Graphics g)
{
g.setColor(Color.red);
g.drawString(“Welcome”,50,50);
g.drawLine(20,30,20,300);
g.drawRect(70,100,30,30);
g.fillRect(170,100,30,30);
g.drawOval(70,200,30,30);

g.setColor(Color.green);
g.fillOval(170,200,30,30);
g.drawArc(90,150,30,30,30,270);
g.fillArc(270,150,30,30,30,180);
}

}

https://youtu.be/HhwVBQ-RbZQ

Add a Comment

Your email address will not be published. Required fields are marked *