Program to design an applet which displays three circles one below the other and fill them red, green and yellow color respectively

Given program will draw three circle one below other with colours red, green and blue respectively. To fill circle with respective colours first we have to set the colour using setColor(Color c) method of Graphics class and then use the fillOval( ) method.


PROGRAM
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;

public class ThreeCircleApplet extends Applet {

 public void paint(Graphics g) {
  
  // First circle filled with RED color
  g.setColor(Color.RED);
  g.fillOval(50, 50, 50, 50);
  
  // Second circle filled with GREEN color
  g.setColor(Color.GREEN);
  g.fillOval(50, 100, 50, 50);
  
  // Third circle filled with YELLOW color
  g.setColor(Color.YELLOW);
  g.fillOval(50, 150, 50, 50);
 }
}

/* <applet code="ThreeCircleApplet" width=200 height=250>
   </applet>
*/

OUTPUT

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



Comments

  1. Whether somebody pursuit of his vital thing, hence he web design agencies or she desires to be accessible that at length, hence that thing is maintained over here.

    ReplyDelete

Post a Comment

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 draw Smiley in Applet