Program to draw different shapes on Applet

This program draws different shapes on applet.
PROGRAM
import java.awt.*;  // Importing awt package
import java.applet.*;  // Importing applet package

public class Shapes extends Applet
{
 public void paint(Graphics g)
 {
  g.setFont(new Font("Cambria", Font.BOLD,15));
  g.drawString("Different Shapes", 15, 15);
  g.drawLine(10,20,50,60);
  g.drawRect(10,70,40,40);
  g.setColor(Color.RED);
  g.fillOval(60,20,30,90);
  g.fillArc(60,135,80,40,180,180);
  g.fillRoundRect(20,120,60,30,5,5);
 }
}
/* <applet code="Shapes" width=200 height=200>
 </applet>
*/

OUTPUT

C:\>javac Shapes.java
C:\>appletviewer Shapes.java



Popular posts from this blog

Program to define a class 'employee' with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

Define a class Student with four data members such as name, roll no.,sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.

Program to input age from user and throw user-defined exception if entered age is negative