2d demo help

hi i m try to make a structure moving i was able to make part of it can somebody help please...

thanks in advance

import java.awt.Container;

import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

publicclass DEMO2{

publicstaticvoid main(String[] args){

JFrame frame =new demoframe();

frame.show();

}

}

class demoframeextends JFrame{

public demoframe(){

setSize(300, 500);

setTitle("Earthquake");

addWindowListener(new WindowAdapter(){

publicvoid windowClosing(WindowEvent e){

System.exit(0);

}

});

Container contentPane = getContentPane();

canvas =new JPanel();

contentPane.add(canvas,"Center");

JPanel p =new JPanel();

addButton(p,"Start",new ActionListener(){

publicvoid actionPerformed(ActionEvent evt){

rigid b =new rigid(canvas);

b.start();

}

});

addButton(p,"Close",new ActionListener(){

publicvoid actionPerformed(ActionEvent evt){

canvas.setVisible(false);

System.exit(0);

}

});

contentPane.add(p,"South");

}

publicvoid addButton(Container c, String title, ActionListener a){

JButton b =new JButton(title);

c.add(b);

b.addActionListener(a);

}

private JPanel canvas;

}

class rigidextends Thread{

public rigid(JPanel b){

building = b;

}

publicvoid draw(){

Graphics g = building.getGraphics();

g.fillRect(x, y, XSIZE, YSIZE);

for(int i=1; i<(fl+1); i++ )

{

x1=x+20; x2=x+XSIZE-20; y1=y-(i*YSIZE); y2=y;

g.drawLine(x1, y1, x1, y2);

g.drawLine(x2, y1, x2, y2);

g.drawLine(x1, y1, x2, y1);

}

}

publicvoid move(){

if (!building.isVisible())

return;

Graphics g = building.getGraphics();

g.setXORMode(building.getBackground());

g.fillRect(x, y, XSIZE, YSIZE);

for(int i=1; i<(fl+1); i++ ){

x1=x+20; x2=x+XSIZE-20; y1=y-(i*YSIZE); y2=y;

g.drawLine(x1, y1, x1, y2);

g.drawLine(x2, y1, x2, y2);

g.drawLine(x1, y1, x2, y1);

}

x += dx;

Dimension d = building.getSize();

if (x < 100){

dx = -dx;

}

if (x + XSIZE + 100 >= d.width){

x = d.width - XSIZE- 100;

dx = -dx;

}

g.fillRect(x, y, XSIZE, YSIZE);

for(int i=1; i<(fl+1); i++ )

{

{

x1=x+20; x2=x+XSIZE-20; y1=y-(i*YSIZE); y2=y;

g.drawLine(x1, y1, x1, y2);

g.drawLine(x2, y1, x2, y2);

g.drawLine(x1, y1, x2, y1);

}

}}

publicvoid run(){

try{

draw();

for (int i = 1; i <= 1000; i++){

move();

sleep(200);

}

}

catch (InterruptedException e){}

}

private JPanel building;

privatestaticfinalint XSIZE = 75;

privatestaticfinalint YSIZE = 25;

privateint x = 99;

privateint y = 400;

privateint dx = 2;

privateint fl = 10;

privateint x1, x2, y1, y2;

}

[7464 byte] By [jas999a] at [2007-11-27 8:54:18]
# 1
123
jas999a at 2007-7-12 21:13:29 > top of Java-index,Security,Cryptography...
# 2
So what's the question ?
bamkin-ov-lestaa at 2007-7-12 21:13:29 > top of Java-index,Security,Cryptography...