applet not displaying

i get the following code to compile but nothing displays in the applet once it is created and i don't understand why. any help would be greatly appreciated.

import java.awt.*;

publicclass Houseextends java.applet.Applet{

double points[][][] ={

{{90,10,0},{10,10,0},{10,80,0},{0,15,0},{10,80,0},{10,10,0},{90,80,0},{90,80,0},{90,90,0}},

{{20,95,0},{20,40,0},{20,40,0},{20,95,0}}};

double a[] ={0,0,0}, b[] ={0,0,0};

int w, h;

int count = 0;

double t = 0;

publicvoid init(){

super.init();

}

publicvoid render(Graphics g){

w = bounds().width;

h = bounds().height;

g.setColor(Color.BLACK);

g.fillRect(0,0,w,h);

g.setColor(Color.black);

animate();

for (int i = 0 ; i < points.length ; i++)

for (int j = 1 ; j < points[i].length ; j++){

transform(points[i][j-1], a);

transform(points[i][j ], b);

g.drawLine(x(a[0]), y(a[1]), x(b[0]), y(b[1]));

}

}

void animate(){

t=.7 + .3 * Math.sin(.1 * count++);

}

int x(double t){return w/2 + (int)(t*w/4);}

int y(double t){return h/2 - (int)(t*w/4);}

void transform(double src[],double dst[]){

dst[0] = t * src[0];

dst[1] = t * src[1];

dst[2] = t * src[2];

}

}

[3653 byte] By [developprogramsa] at [2007-11-27 2:34:12]
# 1

Learn basic for Java GUI and animation on it.

Bellow code barely works but I don't understand what you are trying to do here.

/*

<applet code="MadHouse" width="500" height="500"></applet>

*/

import java.awt.*;

import java.applet.*;

public class MadHouse extends Applet implements Runnable{

double points[][][] = {

{{90,10,0},{10,10,0},{10,80,0},{0,15,0},{10,80,0},{10,10,0},{90,80,0},{90,80,0},{90,90,0}},

{{20,95,0},{20,40,0},{20,40,0},{20,95,0}}};

double a[] = {0,0,0}, b[] = {0,0,0};

int w, h;

int count = 0;

double t = 0;

public void init() {

w = getBounds().width;

h = getBounds().height;

Thread t = new Thread(this);

t.start();

}

public void paint(Graphics g){

g.setColor(Color.black);

g.fillRect(0,0,w,h);

g.setColor(Color.yellow);

for (int i = 0 ; i < points.length ; i++){

for (int j = 1 ; j < points[i].length ; j++){

transform(points[i][j - 1], a);

transform(points[i][j], b);

g.drawLine(x(a[0]), y(a[1]), x(b[0]), y(b[1]));

}

}

}

void animate(){

t = .7 + .3 * Math.sin(.1 * count++);

}

int x(double t) {

return w / 2 + (int)(t * w / 4);

}

int y(double t) {

return h / 2 - (int)(t * w / 4);

}

void transform(double src[], double dst[]) {

dst[0] = t * src[0];

dst[1] = t * src[1];

dst[2] = t * src[2];

}

public void run(){

while (true){

repaint();

animate();

try{

Thread.sleep(500); // half second

}

catch (InterruptedException e){

e.printStackTrace();

}

}

}

}

hiwaa at 2007-7-12 2:51:24 > top of Java-index,Java Essentials,New To Java...