Saturday, 12 October 2013

Applet Program to draw Vertical Oval Patterns

//Applet Program to draw Vertical Oval Patterns
//Developed by Ahlam Ansari
import java.awt.*;
import java.applet.*;
/*
<applet code=OvalPattern.class width=500 height=500></applet>
*/

public class OvalPattern extends Applet
{
  public void paint (Graphics g)
  {
    for(int i=0; i<=4;i++)
    {
        if (i%2==0)
        {
            // Draw a red, filled circle:
            g.setColor (Color.red);
            g.fillOval (120,i*60+10,150,50);
        }
        else
        {
            // Draw an unfilled blue oval below it:
            g.setColor (Color.blue);
            g.drawOval (120,i*60+10,150,50);
        }
    }
  }

}

/*
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>javac OvalPattern.java

C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>appletviewer OvalPattern.java

*/

No comments:

Post a Comment