Saturday 12 October 2013

Applet Program to draw Horizontal Oval Patterns

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

public class HOvalPattern 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 (i*160+10,120,150,50);
        }
        else
        {
            // Draw an unfilled blue oval below it:
            g.setColor (Color.blue);
            g.drawOval (i*160+10,120,150,50);
        }
    }
  }

}

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

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

*/

No comments:

Post a Comment