PA01

 

Home
My Work
Links
Photo Gallery
About Me

 

/**** Author: Walid Abbas Bahsow

 **   E-Mail: wabsnet@yahoo.com

 **   Date: Sunday 23rd of March, 2003

 ****/

 

/**
 * This applet draws lines from the top left and right
 * corners down.
 */

 

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class PA01 extends Applet {

            final static int B = 5;

            public void paint(Graphics g) {

                        int w = getSize().width;
                        int h = getSize().height;
                        int offset = 30;
                        int x = offset;
                        int y = w - offset;
                       

                        // These 4 instructions draw a border line around
                        // the applet.

                        g.drawLine(B,B,w-B,B);
                        g.drawLine(B,B,B,h-B);
                        g.drawLine(w-B,B,h-B,w-B);
                        g.drawLine(B,w-B,h-B,w-B);
                       
                        // the following 2 loops are for drawing the lines inside the
                        // borders drawn above.

                        for (int i = 0; i < 10; i++) {
                                    if (x <= w-B) {
                                                g.drawLine(B,B,x,h-B);
                                    }
                                    x += offset;
                                    if (y >= B)
                                                g.drawLine(w-B,B,y,h-B);
                                    y -= offset;
                        }
                        y = h - B;
                        for (int i = 0; i < 10; i++) {
                                    if (y >= B){
                                                g.drawLine(B,B,w-B,y);
                                                g.drawLine(w-B,B,B,y);
                                    }
                                    y -= offset;
                        }
            } // End of paint
} // End of class PA01

 

 

 

Home | My Work | Links | Photo Gallery | About Me | Programming Assignment #1 | Object Oriented Programming |
| Sign Guest Book | View Guest Book

 

This site was last updated Sunday March 23, 2003