|
images building
i am having five off screen images i had load it with the help of Imageicon class and i had drawn it using paint method
i just want the images to be placed on the top of each one in vertical format like a building using threads
could u plz help with this code and and each image width and height is of 32*32
import java.awt.*;
import javax.swing.*;
class d extends JComponent implements Runnable
{
Image r;
Image g;
Image n;
Image t;
int x=0;
long floor=329;
public void run()
{
r=new ImageIcon("1.png").getImage();
g=new ImageIcon("2.png").getImage();
n=new ImageIcon("3.png").getImage();
t=new ImageIcon("4.png").getImage();
try
{
while(x!=floor)
{x++;
repaint();
Thread.sleep(10);
}
}
catch(Exception e)
{
}
}
public void paint(Graphics q)
{
q.drawImage(r,229,x,this);
}
}
class f
{
public static void main(String args[])
{
d v=new d();
JFrame b=new JFrame("sdfdsf");
b.getContentPane().add(v);
b.setVisible(true);
b.setSize(300,400);
(new Thread(v)).start();
}
}
if the code is incomplete then plz help iam stuck in this program
|