JAVA Moja……..

Posted: June 4, 2011 in Applet, Applet Programming, Java

i was just practicing my java graphics skill………. (really amateur skills)…..Just done this…….

import java.applet.Applet;
import java.awt.*;
/**
 *
 * @author Rakibz
 */
public class cube extends Applet {
    /**
     * Initialization method that will be called after the applet is loaded
     * into the browser.
     */
    int a,b;
    void cube(int x,int y,int p,Graphics c)
    {
        int xa,xb,xc;
        int ya,yb,yc;
        xa=x+p/2;
        xb=x+p;
        xc=x+p+p/2;
        ya=y+p/2;
        yb=y+p;
        yc=y+p+p/2;
        int xp[]={x,xb,xc,xc,xa,xa,xc,xb,xb,xc,xa,xa,x,x,xb,x,xa,x};
        int yp[]={y,y,ya,yc,yc,ya,ya,y,yb,yc,yc,ya,y,yb,yb,yb,yc,yb};
        c.drawPolygon(xp, yp, xp.length);
    }

    public void paint(Graphics g)
    {
        cube(40,50,100,g);
    }
}

It’ll create an Applet with a CUBE drawn on it……..  Its fun……. 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s